Skip to content

Instantly share code, notes, and snippets.

@mikermcneil
Last active January 19, 2016 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikermcneil/864b930a67b0d00d3d8b to your computer and use it in GitHub Desktop.
Save mikermcneil/864b930a67b0d00d3d8b to your computer and use it in GitHub Desktop.
Example usage of a hypothetical `moveTurtleDown` machine in JavaScript.

Example usage of a hypothetical moveTurtleDown machine in JavaScript

moveTurtleDown({
  meters: 0.42,
  howFast: 'fast'
}, {
  success: function(newCoordinates) { ... },
  ranOutOfGas: function() { ... },
  fellOffCliff: function(didTurtleSurvive){ ... }
});

(where the ...s are implementations for callback functions passed in from userland. success is like the standard return value of a function, while the other two exits can be thought of like two different types of exceptions the machine could throw)

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