This project is archived and is in readonly mode.

#1153 ✓invalid

Class events fail on first failure

Reported by Arieh | January 24th, 2011 @ 01:24 PM | in 2.0 (closed)

OK - so title isn't very well understood but here's the main issue-
Whenever a broken function is fired using fireEvent, it will break the event loop.
This is not standard DOM events behavior, and it creates a blind dependency between different objects that might be listening to the same shared object.
I've set up a demo page here:

the first anchor shows how a Class behaves. The second how a DOM element behaves, and the third shows a fixed version of Events.
The fix itself is quite simple:

simply making each function fire with a setTimeout of 0 would solve this. This line (and the following line):
simply would be replaced with

fn.delay(delay || 0, this, args);

I'll mention that this isn't a theoretical problem. On an app I'm working on, I have a Dispatcher Class that is used by many other objects. During dev, whenever there's a bug with one of these listeners, it hurts all others who listen to the same events. As I understand it, events are supposed to be a very useful means of decoupling between objects. This makes the events API unsafe for shared environments (a bit of exaggeration but you get my point).

Currently I simply use the fix above, but IMO this should be a part of the main implementation

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins