Seeking guidance for a design query, I am dealing with a JavaScript script that is heavy on logic. It is structured using promises as shown below:
init()
.then(result => doSomethingA(result))
.then(result => doSomethingB(result))
.then(result => loadVueApp(result))
The loadVueApp()
function trigger the following actions:
new Vue({
el : '#app',
render : h => h(App)
});
This code renders the Vue app, allowing user interaction to navigate screens and make selections stored in a global EventBus
type component.
My question pertains to passing user choices back to the tower of promises. Is this necessary, and if so, how should it be handled?
One approach is to resolve the loadVueApp
immediately upon the app's appearance, then later initiate a function call back to the script containing heavy logic - although this method lacks elegance.
Any insights or suggestions would be appreciated.
Thank you in advance.