-
Notifications
You must be signed in to change notification settings - Fork 264
[Bug 1527723] Allow setting defaults for loader virtual components #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
djmitche
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loading is an async operation, so the suggested method of importing monitor would require an await (and thus can't be used at the module level).
Also, it seem you've removed the .catch(..) from the main.js's -- what happens if loading fails? Unless I'm missing something, maybe a fix for that is to define a sub-function that will automatically catch and handle async errors, such as load.main(process.argv[2]).
|
Ah yeah, we can do: const loader = require('./main');
const monitor = await loader('monitor').prefix('foo');Ah yeah, we need to catch the error because of unhandled rejection stuff. I can fix that. Does this general plan make sense though? |
| "dependencies": { | ||
| "assume": "^2.1.0", | ||
| "debug": "^4.1.0", | ||
| "lodash": "^4.17.11", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you might like that :)
djmitche
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, the overall idea makes sense!
This simplifies the setup at the bottom of the
main.jsin our services and allows for easier requiring of components in modules that otherwise are not loaded by the loader. An example of what I want to do is:This way we can configure monitor in one place, using configuration loaded in the same way as all of our other components but also allow people to have modules that exist outside the
main.jssetup.Bugzilla Bug: 1527723