Skip to content

Instantly share code, notes, and snippets.

@deanrad
Forked from CrabDude/callback_contract.md
Last active August 29, 2015 14:27
Show Gist options
  • Save deanrad/37533ad30e3cd40dd68c to your computer and use it in GitHub Desktop.
Save deanrad/37533ad30e3cd40dd68c to your computer and use it in GitHub Desktop.
Node.js Callback Contract

#callback/errback contract

  1. Function that takes 2 arguments
    • first argument is an error
    • second argument is the result
    • Never pass both
    • error should be instanceof Error
  2. Must never excecute on the same tick of the event loop
  3. Must be passed as last argument to function
  4. Return value is ignored
  5. Must not throw / must pass resulting errors
  6. Must never be called more than once
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment