-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Events.trigger with arrays #12
Comments
hrm this is due to the this is for collection evnet bubbling? this test passes, which is: perhaps it needs to be changed, though it may be somewhat breaking. the events fire exactly like in MooTools Class.Events but I can override them since I have a local copy reimplementing them for versatility. |
Never noticed Mootools Events has the same behaviour with Arrays - I've always called them with objects. Anyway I'll cleanup my changes in my fork and you can decide how you want the behaviour to function. |
btw is array.flatten what you want to do for passing events? Itll run into the same issue. Unless I'm overlooking something I'd write the function like this:
|
this is now slightly different in the new event imlementation. https://github.com/DimitarChristoff/epic/blob/master/lib/index.js#L33-L148 |
That's essentially how I ended up deciding to implement it as well megawac@2f1f5fd#diff-f05ace420865a960e67f1030e352afd8R48 |
When a event is triggered, eg model property change, if the args is an array, events is going to apply each listener with the array. With all other data types the listeners will be applied with an array containing the value.
For example:
myModel.set("x", {a:1,b:2})
calls all listeners with first argument: args({a:1,b:2}).
However
myModel.set("y", [1,2])
calls all listeners with arguments: args(1, 2) instead of args([1,2])
Hope that makes sense I'm working on a fix.. For now I just changed trigger a bit with this dirty line :( :
args = Type.isArray(args) ? [args] : Array.from(args);
The text was updated successfully, but these errors were encountered: