Hi!
I dont like sequences and queues. I'm also not very good at js coding. You must correct me if the next idea looks or does something wrong.
Point 1
We no longer trust loading into the context of the entire project in V8
Point 2
We have to use bundlers for correct loading. The main candidates are Webpack and TypeScript.
Bundlers have a flaw. They don't reverse deployment to developer code. This means that you cannot turn a bundler into code without an external version control system (git as standart).
Point 3
Instead bundlers we can use the singleton pattern (as you know modules aren't supported too)
Suggestion
/**
*
*/
class App {
/**
*
*/
constructor() {
if (!App._instance) {
this.data = {
someValue: 1,
};
App._instance = this;
}
return App._instance;
}
/**
*
* @param {*} e
*/
onOpen(e) {
const f = Object.assign({}, e);
f.someValue = this.data.someValue;
console.log(f);
}
/**
*
* @param {*} e
*/
onEdit(e) {
console.log(e);
}
}
I use the App class to centralize the business logic of the application.
If I need to use the features of other classes, then I can copy them without changing.
The restrictions on this class are as follows:
- singleton
- only business logic
- determine the properties of the application at startup
Any suggestions and criticism are welcome.