-
Notifications
You must be signed in to change notification settings - Fork 641
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
Emit 'load' events on Loader and Environment instances #1196
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1196 +/- ##
==========================================
- Coverage 89.94% 89.81% -0.14%
==========================================
Files 22 22
Lines 2985 2995 +10
==========================================
+ Hits 2685 2690 +5
- Misses 300 305 +5
Continue to review full report at Codecov.
|
|
||
The 'load' event gets emitted whenever a Loader retrieves the source of a | ||
template. It can be listened to in order to determine template dependencies | ||
at runtime. The arguments emitted to the callback are: |
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.
s/emitted/passed/
@@ -59,4 +60,26 @@ class Obj { | |||
} | |||
} | |||
|
|||
module.exports = Obj; | |||
class EmitterObj extends EventEmitter { |
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.
Probably not worth changing now, but other EventEmitters are available, e.g. little-emitter, which is smaller and doesn't require the addition or modification of a superclass:
const EventEmitter = require('little-emitter');
class Environment {
constructor() {
EventEmitter(this); // mix in `emit`, `on` etc.
}
}
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 went with the default webpack events shim just because it's so widely used, it was easy, it's well documented, and it only added 1.5K gzipped to the minified builds.
Summary
Adds a 'load' event to
Environment
andLoader
instances, to allow runtime dependency detection.Closes #1153
Checklist
I've completed the checklist below to ensure I didn't forget anything. This makes reviewing this PR as easy as possible for the maintainers. And it gets this change released as soon as possible.