Created
February 15, 2010 21:06
-
-
Save guanix/304990 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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