-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Conversation
do you have tests? benchmarks appear to be on par with HEAD nits: there's a few EOL whitespace errors. you should wrap the lines in the docs. |
I have fairly comprehensive tests, but they are written using |
v8 inlines the constructor for |
+1 to this patch including tests. I'm +0 on the names of things ;) My immediate reaction to the *Any names and .un() is negative but to be honest I can't think of a better name so I don't have any room to complain. |
I'm +0 on namespaces. +1 on the catchall listener, there was a thread about that a while ago that was pretty unanimous in favor of adding it. |
I'll review the code changes more closely in the next day or two. Feature-wise, it all looks good to me. I'm glad we're going about this carefully, this path is hot like magma. |
+1 Clearly; obviously I'm a little baised since I helped write it :-D @isaacs This pull-request is the result of a lot of concerted effort from @hij1nx @DrJackal and myself, the magma will flow in the hot paths (i.e. w/o @mikeal Namespaces are really useful, have you taken a look at how they are used in |
I know namespaces can be useful, it's not a -1, it's a +0. It's something I won't use but don't dislike and generally don't have a strong opinion about one way or the other :) |
-1 Namespaces: on the fence, convince me. onMany: somewhat useful, I suppose, but something you can stitch together yourself with little effort. Wildcards: this has been hashed out on the mailing list but the tl;dr version is that no one could present a good use case except debugging and that's something you can duct-tape together in 2 minutes. function log_events(ee) {
var fun = ee.emit;
ee.emit = function() {
console.error(arguments);
return fun.apply(ee, Array.prototype.slice.call(arguments));
};
return ee;
} All in all it seems like a lot of extra code for little gain. |
+1 |
@bnoordhuis Have you taken a look at how http://blog.nodejitsu.com/distribute-nodejs-apps-with-hookio |
the question is less about how useful it would be to third party modules and more about what we would use it for in core. if there isn't a single usecase for it in core then it probably doesn't belong. cool stuff doesn't have to be in core, in fact there is an argument to be made that more cool stuff in third party modules is a better thing for the community long term. that said, a listener for all events has been brought up many times as a need for debugging. |
@indexzero: Okay, I see how wildcards and namespaces can be useful. But I agree with @mikeal that it's something that core doesn't have any use for (right now anyway) so it should stay in user land. Let's say -0.5 instead of -1. |
You can do the namespacing with current EE, foo::bar is just a simple string, the wildcard feature is what is new. |
@bnoordhuis @mikeal -- I am a proponent of a sparse core <3 But I also believe namespaces are a succinct and well known mechanism for event characterization. As we build more complex event based systems using node, we should establish simple and well known conventions for describing them. This patch provides basic progressive enhancement that does not impose upon the existing node programming style or APIs. Therefore I'm compelled to propose it as a core commit. |
As long as there's no breakage, and no major performance penalty, I don't see why it shouldn't be in core. It is incredibly useful, and the simple matter that core modules don't use it doesn't mean they can't benefit from them in the future. |
@hij1nx "As we build more complex event based systems using node". That's the issue though isn't it. This is intended for use by people using node, not by core itself. It's not that I don't think this pattern is a good one, but adding it would be blessing it. We're trying not to do that. Blessing a particular pattern can reduce innovation on top of node.js in the rest of the community, and it's still very early. If this patch made it in hardly anyone would use your eventemitter2 library because it's primary offerings will be in core. That library is where most of the current innovation is happening around the patterns you propose here, if nobody is using it where does that innovation happen? And if in 6 months you have a great idea that compliments or potentially changes some of this stuff you won't have a lot of users to give you feedback and you'll just be trying to put more of it in to core and it'll be even harder and hit considerably more skepticism. |
+0 from me. Doesn't really matter to me either but there are plenty of "nice to have"s that could be in core and gain wider adoption, a better sprintf implementation, blah blah. |
I really like EventEmitter, and I think it's a useful abstraction and guide for how to write node programs. I like these improvements, but I'm torn about whether I think they should go in core. I would probably not use this if it weren't in core, but I probably would if it were. I think the real question is whether we think this is how people should be writing node programs. By putting it in core, it basically says, "you should do it this way." For listeners that can catch multiple events, it'd be useful if they were passed the original event name that matched. |
The EventEmitter2 library came from a need, the need to be more expressive when interacting with events. Since node APIs make heavy use of EventEmitter. I believe this is less endorsing a pattern than maturing an existing one. @mranney for the case where a wildcard is used, |
I personally don't like the the above example, but I see a lot of third-party modules blindly eventing their objects. I think there are too many namespaces included in this commit, and there might be a number of unknown conflicts with older modules. |
The EventEmitter2 library came from a need, the need to be more expressive when interacting with events. Since node APIs make heavy use of EventEmitter, I believe this is less endorsing a pattern than maturing an existing one. @mranney for the case where a wildcard is used, Edit: @mikeal i've been intentionally quite conservative with this work, and i will continue to be, i think it should stay simple. @codenothing you lost me with " I think there are too many namespaces included in this commit, and there might be a number of unknown conflicts with older modules." =) |
@hij1nx I think the issue is that "init" is a fairly common method name, and calling "this.init()" might not call EventEmitter.prototype.init. How badly does it affect the benchmarks to change that to EventEmitter.prototype.init.call(this);, or just inlining the "init" functionality into the EventEmitter constructor? |
(that is, "the issue" = "the thing that @codenothing is complaining about". Please correct me if I missed the point of your comment, @codenothing.) |
his example assumes you need to call it, you actually should never need to call init(), init gets called for you...
Edit: it has become quite clear to me over time that people are often unsure how |
I was reluctant to bring this up because it is clearly part of a larger discussion. My apologies to all for such hubris. From what I've gleaned from @ry, a real goal for core is to be able to facilitate somekind of distributed communication between node processes. Clearly the Specific replies @mikeal We have a blessed version of IPC in @mranney Why would you not use this if it wasn't in core? The separate EventEmitter2 module will continued to be maintained by @hij1nx and the rest of Nodejitsu because it adds some sugar for using it in the browser that doesn't belong in node for those who don't want to use something like browserify. @hij1nx I believe that @isaacs @codenothing are correct. To my understanding when the |
Sorry, should have been more clear. What I'm getting at is there is potential for many naming conflicts.
Are all new properties created with this commit. For such a highly extended object, there are bound to be naming conflicts within existing modules. I like the addition, it just needs to be well documented. |
@hij1nx haha yeah definitely a bit different. It's a bit of a tough call, saying not to include something unless node core uses it doesn't really work either because there are still quite a few things core it-self doesn't really provide. I guess the major thing is that if it can be done reasonably as a third-party module or not. It's cool it just seems like a similar to something like the request module where (in most cases at least) is just extending and the API additions are still optional but where do you draw that line. I dont know a good answer for that either, just seems like |
@visionmedia you raise some great points. As a community, I believe we are motivated, not just to keep core sparse, but to keep the mental model simple and let growth emerge at the perimeter. So I believe the question in regards to this patch is centered around how disruptive these changes are to the mental model of node developers and how it affects innovation potential. It feels like either an executive decision at this point, or at least a core committers decision. |
Wow. Good stuff. My gut reaction to wildcards is "I'm not going to enjoy a lot of what people do with them", so +0 from me on that, but namespaces feel relatively right. |
|
@mikeal constructor inlining is not implemented yet. only normal calls are inlined by crankshaft. |
-1 on making this part of core until there is an actual need for these features in the core itself. Making this part of the core puts all other alternative patterns into a very weak position, which I don't think is beneficial for the community, at least not yet. |
@Gozala the idea that something is only useful if its useful internally, is itself debatable as we've already discussed. Adding value to user-land also has validity. |
@Gozala, of course its fair to state your case! but again, i do not believe this patch is a |
I'd like to elaborate on the scenario that I outlined in my previous comments in the interest of both those now joining the comment thread, and solidifying a high-level thought into a concrete example. That is, what does the current If you have not seen @isaacs talk on "Node digs DIRT", now would be a good time. I've prepared a sample centered around DIRT / ETL based applications for which node has clear limitations from the V8 heap. If we want to support these scenarios, this should go into core. In my opinion, this isn't some abstract user-land problem, this is grunt-work data processing that we need to be capable of doing: |
-1 The only feature here that I recall wanting is namespaced events and that only one time for a very specific use case. +1 For leaving it in userland. |
damn. @indexzero presents a very compelling argument. a lot of -1's feel nullified. |
-1 on merging this as a whole. This is too big of a change to be reasonably discussed by the amount of people involved in this discussion. We need to split this effort into multiple patches which we can discuss separately, one after another. I therefor suggest that we focus on the catch-all listener feature first. I feel like:
--fg |
I agree with @felixge. this is a big change. It needs to be broken into smaller parts. There is a lot of knee-jerk reaction and a lot of noise in this thread. This needs to go to a smaller group. |
Ok, had a chance to read through the changes more carefully. I think that this is overall a very good patch, and the benchmarks seem to be a bit faster than on master, which is always nice. The code is very understandable, and seems to work as documented. Some relatively minor issues:
|
I'm +1 ... I think. |
I've personally always liked the namespaces in jQuerys events but I guess it might be a bit limited as it assumes a certain style? But an example could be:
I guess it's the ":" (or even worse "::") that looks like dirty xml namespaces to me when the "." looks more like clean js/json to me...but I thought I'd just throw this into the mix |
Namespaces aside, if this does go in eventually, I have one small suggestion. Rename the removeListener alias, |
@chjj++ |
this bikeshedding is now out of control. i think @felixge is right, we need to break this up in to a few different patches, it would make this a lot easier. |
@mikeal, i agree. but I also dont agree. @isaacs, i get on those changes immediately. @ry let's put the patch in =) @chjj & @visionmedia this is actually a very common short cut in browser frameworks, thats why i adopted it, but i also really like |
really? I've never seen |
@hij1nx haha, yeah, after posting (shame on me) I saw that in the diffs too. Another difference is the implicit wildcard i.e. ".http" instead of "*.http". Might be slightly harder to read perhaps, but it sure looks clean if you ask me... |
@visionmedia with all due respect, i whole heartedly disagree that it is |
@hij1nx as a whole, but each method etc could be a commit that people could individually be accepted/commented on etc |
@visionmedia well, the commit is actually pretty small, we're talking about |
size of this discussion is dwarfing the size of the commit. breaking it up reduces the surface area for discussion :) |
Hello All. Here is the eventEmitter that I've been working on. I have added a few simple features, none of which are breaking changes. These changes (namespace/wildcards etc) have been documented in
doc/api/events.js
. This code is passing all release tests.@ry, as discussed there does not seem to be a noticeable increase in performance of the
ab
tests despite the performance increase of the javascript in isolation.