-
Notifications
You must be signed in to change notification settings - Fork 780
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
Events: QUnit logging system uses EventEmitter #644
Conversation
Shoot, I apparently need to rebase this. Hold tight. |
Rebased. |
@jzaefferer @Krinkle @leobalter @scottgonzalez: Reviews, please? |
I think this needs to wait until we get some feedback from other frameworks on the shared reporter. I just commented on the discussion issue, hopefully we get some participation there. |
} | ||
|
||
// Initialize collection of this logging callback | ||
if ( QUnit.objectType( config.callbacks[ type ] ) === "undefined" ) { |
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.
Can't this just be if ( !config.callbacks[ type ] )
?
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.
Yes, it was just copied from the old code.
Updated per @scottgonzalez's comments (+1 more guard for undefined |
|
Fine by me. I just repurposed what was already there for the old logging callback system.
That's the idea, yes. I think it's just easier to leave all of the logs tests in place for now and axe them completely in |
Eliminated |
return QUnit; | ||
}, | ||
|
||
off: function( type, listener ) { |
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.
What's the usecase of removing event listeners?
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.
- Standard EventEmitter behavior/API.
- Thinking ahead to Reporters, e.g. if Reporters become an event-driven interface, then we would need to remove event listeners if the Reporters (especially the default reporter) can be removed/disabled.
Exporting Otherwise, see my inline comments. |
Agreed... hopefully. 🙏 |
I should also add a test to verify the prevention of duplicate listeners. |
I'm be much more comfortable landing this with just |
Can do. We will definitely need QUnit.addReporter = function( reporter ) {
var emitter = {
on: QUnit.on,
emit: emit,
off: off
};
reporter.register( emitter );
}; |
That sounds good to me. Either way, we can add that later without hassle, and will have much less docs (=XML!) to write to release this. And if we're wrong about a lot of this stuff, there's less mess to fix. |
Updates:
|
Rebased from latest |
faf5e97
to
150ecaf
Compare
}); | ||
|
||
QUnit.load = function() { | ||
config.pageLoaded = true; | ||
|
||
emit( "runStart", { |
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.
Shouldn't runStart
replace begin
? This looks like it was missed when rebasing.
Apart from the one issue above, this looks good. I still don't think we should land this until there's some more consensus on the js-reporter end. Changing these names along with a new method for binding the callbacks is fine, but once we release this, I don't want us changing those names again. |
FYI, my git history got very messed up while trying to rebase this branch so I unfortunately felt the need to squash it to clean things up. |
I doesn't look we're gonna have progress fast enough on js-reporters to wait to land this one. I believe it's good to rebase and be ready to land this to advance on 2.0 |
@JamesMGreene, do you want to work on this? If you're busy I'll continue the work on the top of your commit (keeping the authorship credits). |
I'm closing this as the discussion should be followed at #882 |
Fixes #422.
Even though this is earmarked for
v2.0
, it is 100% backward compatible.Critique away. 😉🍷