Skip to content

Commit 5a2864b

Browse files
committed
sameStateTransitions
1 parent c0333e6 commit 5a2864b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

state-machine.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
fsm.transitions = function() { return (transitions[this.current] || []).concat(transitions[StateMachine.WILDCARD] || []); };
8484
fsm.isFinished = function() { return this.is(terminal); };
8585
fsm.error = cfg.error || function(name, from, to, args, error, msg, e) { throw e || msg; }; // default behavior when something unexpected happens is to throw an exception, but caller can override this behavior if desired (see github issue #3 and #17)
86+
fsm.sameStateTransitions = !!cfg.sameStateTransitions;
8687
fsm.states = function() { return Object.keys(transitions).sort() };
8788

8889
if (initial && !initial.defer)
@@ -159,7 +160,7 @@
159160
if (false === StateMachine.beforeEvent(this, name, from, to, args))
160161
return StateMachine.Result.CANCELLED;
161162

162-
if (from === to) {
163+
if (from === to && !this.sameStateTransitions) {
163164
StateMachine.afterEvent(this, name, from, to, args);
164165
return StateMachine.Result.NOTRANSITION;
165166
}

state-machine.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)