-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
'use strict'; | ||
|
||
// A simple class system, more documentation to come | ||
const EventEmitter = require('events'); | ||
const lib = require('./lib'); | ||
|
||
function parentWrap(parent, prop) { | ||
|
@@ -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 commentThe 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 commentThe 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. |
||
constructor(...args) { | ||
super(); | ||
// Unfortunately necessary for backwards compatibility | ||
this.init(...args); | ||
} | ||
|
||
init() {} | ||
|
||
get typename() { | ||
return this.constructor.name; | ||
} | ||
|
||
static extend(name, props) { | ||
if (typeof name === 'object') { | ||
props = name; | ||
name = 'anonymous'; | ||
} | ||
return extendClass(this, name, props); | ||
} | ||
} | ||
|
||
module.exports = { Obj, EmitterObj }; |
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/