Thanks for the reply, Alex.

Is it possible for nodejs to provide such semantic guarantees in future? 
Have a defined order of invocation of listeners comes very handy in many 
cases. And I assume there should not be a performance loss in providing 
such guarantees.

-Chaoran

On Friday, October 4, 2013 2:03:05 PM UTC-5, Alex Kocharin wrote:
>
>
> No, they are implementation-dependent. So unless events module will get "5 
> - Frozen" stability level, I wouldn't count on this hack to last forever.
>
> But there's a good chance that it won't be changed in stable branch.
>
>
> On Friday, October 4, 2013 8:09:40 PM UTC+4, Chaoran Yang wrote:
>>
>> Questions 1: Are event listeners always invoked synchronously?
>>
>> For example, If I do:
>>
>> event.on("end", function() {
>>   console.log("end");
>> });
>> event.emit("end");
>> event.removeAllListeners();
>>
>> Does this code always prints "end" every time?
>>
>> Question 2: Are event listeners always invoked in the order of they are 
>> attached?
>>
>> For example, if I do:
>>
>> event.on('end', function() {
>>   console.log('end');
>> });
>> event.on('end', function() {
>>   event.removeAllListeners();
>> });
>> event.emit('end');
>>
>> Does this code always prints "end" every time?
>>
>> For all tests I ran, the answers to both of these questions are YES. But 
>> I'm not sure whether these are semantics I can rely on across difference 
>> versions of nodejs. Does nodejs provides these semantics guarantees, or are 
>> they implementation dependent?
>>
>> Thanks,
>> Chaoran Yang
>>
>>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to