[Bug 1527723] Allow setting defaults for loader virtual components#228
Merged
[Bug 1527723] Allow setting defaults for loader virtual components#228
Conversation
djmitche
reviewed
Feb 13, 2019
Collaborator
djmitche
left a comment
There was a problem hiding this comment.
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]).
Contributor
Author
|
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", |
Contributor
Author
There was a problem hiding this comment.
I thought you might like that :)
djmitche
approved these changes
Feb 14, 2019
Collaborator
djmitche
left a comment
There was a problem hiding this comment.
Yep, the overall idea makes sense!
jhford
reviewed
Feb 14, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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