Created
April 29, 2015 22:08
-
-
Save pelonpelon/aad56813a99946d64f38 to your computer and use it in GitHub Desktop.
Example finite state machine - credit: Nijiko Yonskai (https://github.com/Nijikokun)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function state (namespace) { | |
if (!namespace) return internalState[internalState.length - 1] | |
internalState.push([namespace, options]) | |
m.redirect(namespace, options) | |
} | |
function goto (namespace, options) { | |
return function (e) { | |
e.preventDefault() | |
e.stopPropagation() | |
state((typeof namespace === 'function' ? namespace() : namespace), options) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment