Skip to content

Instantly share code, notes, and snippets.

@guanix
Created February 15, 2010 21:06
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 guanix/304990 to your computer and use it in GitHub Desktop.
Save guanix/304990 to your computer and use it in GitHub Desktop.
// fileIO style continuables example
// Note: All the three examples here are done based on the *same* API,
// namely the fileIO continuables API
// "Promise lite" style with either:
readFile("11.txt")(either(
function (e) {
// handle an error
},
function (obj) {
// handle a success
}));
// bentomas continuable style:
readFile("11.txt")(function (succeeded, obj) {
if (succeeded) {
// handle success
} else {
// handle error
});
// Pure continuable style, agnostic to number of outcomes:
readFile("11.txt")(function (x) {
if (x[0]) {
// handle success
} else {
// handle error
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment