Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Use own EventEmitter #128

Merged
merged 13 commits into from May 2, 2014
Merged

Use own EventEmitter #128

merged 13 commits into from May 2, 2014

Conversation

OliverJAsh
Copy link
Contributor

If you think the object construction looks strange, read this for an argument against new, instanceof, ES6 classes, etc.

If this looks good I will move it out into a partial/module.

@@ -185,7 +225,8 @@ define([
// observer.disconnect();
}

Scribe.prototype = Object.create(EventEmitter.prototype);
var eventEmitter = EventEmitter.new();
Scribe.prototype = Object.create(eventEmitter);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I am using the OLOO approach for EventEmitter, I would like to be consistent so I’m thinking of (in the future) refactoring the Scribe constructor to use the same approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean I'm going to have to read that goddamn long OO diatribe? :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Essential reading. You only have to read it once :-P

listener.callback.apply(null, args);
});
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't really belong in this file, or does it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit tests?

Also: unregister? "off", or make "on" return a handle with a dispose method, depending on convention vs ease...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this looks good I will move it out into a partial/module.

:-P

And they are things to add later https://github.com/guardian/scribe/pull/128/files#diff-416a38bb2d802283901df66e442a750bR53

Yes, I will write some unit tests.

@theefer
Copy link
Contributor

theefer commented Apr 25, 2014

Looks sane, nice to remove a dependency for little extra cost. See remaining comment on listeners structure.

@OliverJAsh
Copy link
Contributor Author

@theefer Ping.

// TODO: unit test
// Good example of a complete(?) implementation: https://github.com/Wolfy87/EventEmitter
function EventEmitter() {
this._listeners = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean for this to be an empty object instead?

@theefer
Copy link
Contributor

theefer commented May 2, 2014

Worth doing a good manual test via Composer after this is merged, in case we missed something.

@theefer
Copy link
Contributor

theefer commented May 2, 2014

👍

OliverJAsh pushed a commit that referenced this pull request May 2, 2014
@OliverJAsh OliverJAsh merged commit 5088eb1 into master May 2, 2014
@OliverJAsh OliverJAsh deleted the oja-event-emitter branch May 2, 2014 10:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants