-
Notifications
You must be signed in to change notification settings - Fork 3
(update) added event argument hitchhiking #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
075dd51
38da5ea
4ff594c
e80cfe3
8672c5b
d19ecc0
9df09f8
db97cad
ad05d32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,7 +61,9 @@ | |
|
|
||
| function buildEventShortcut(name) { | ||
| states[name] = states[name] || function () { | ||
| states.trigger(name); | ||
| var args = Array.prototype.slice.call(arguments); | ||
| var arr = args.sort(); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this sort call? This is really unexpected in my experience, I'd expect the order or arguments to never change? |
||
| states.trigger(name, arr); | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -114,18 +116,19 @@ | |
| return curr && curr.name; | ||
| } | ||
|
|
||
| , setState: function (name) { | ||
| , setState: function (name, args) { | ||
| var prev = me.currentState(true); | ||
| currentState = me._states[name]; | ||
|
|
||
| me.onChange(me.currentState(), prev.name); | ||
| is(currentState.enter, 'Function') && currentState.enter(); | ||
| me.onChange(me.currentState(), prev.name, args); | ||
| args.push(me.currentState()); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why put the current state at the end of the list of arguments? Wouldn't it be more predictable to have the current state as the first argument? |
||
| is(prev.leave, 'Function') && prev.leave(); | ||
| is(currentState.enter, 'Function') && currentState.enter.apply(undefined, args); | ||
| } | ||
|
|
||
| , trigger: function (eventName) { | ||
| , trigger: function (eventName, args) { | ||
| var nextState = me.currentState(true).events[eventName]; | ||
| nextState && me.setState(nextState); | ||
| nextState && me.setState(nextState, args); | ||
| } | ||
|
|
||
| , _states: {} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These specs are failing for me: https://cl.ly/2C283C1l1w2y