Skip to content

Conversation

@Zukzuk
Copy link

@Zukzuk Zukzuk commented Mar 22, 2016

For this fine state machine to be compatible with our envisioned payment workflow implementation, I need to be able to update our database inside the stateMachine itself. With this change we can add arguments to the event method and use them in the enter phase of the state change. See test for implementation

@wheeyls
Copy link
Owner

wheeyls commented Feb 10, 2017

Lol it's absurd how long ago you submitted this, and I just saw it now. Gonna have to ask Github to work out their notifications, I'm on this site every day.

states[name] = states[name] || function () {
states.trigger(name);
var args = Array.prototype.slice.call(arguments);
var arr = args.sort();
Copy link
Owner

Choose a reason for hiding this comment

The 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?

me.onChange(me.currentState(), prev.name);
is(currentState.enter, 'Function') && currentState.enter();
me.onChange(me.currentState(), prev.name, args);
args.push(me.currentState());
Copy link
Owner

Choose a reason for hiding this comment

The 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?

;

newStates.withParams('a string', {some: 'data'});
q.equal(_in1, 'a string');
Copy link
Owner

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

@wheeyls
Copy link
Owner

wheeyls commented Feb 10, 2017

Curious if you're using these changes in production anywhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants