Skip to content

Instantly share code, notes, and snippets.

@toddzebert
Last active March 8, 2017 04:10
Show Gist options
  • Save toddzebert/5958be630e81bb9ba16fb6931c339c88 to your computer and use it in GitHub Desktop.
Save toddzebert/5958be630e81bb9ba16fb6931c339c88 to your computer and use it in GitHub Desktop.
"async" partial application functions for callback w/"all" & "race" examples
// requires https://gist.github.com/toddzebert/95bcc9b50febad0bb9680d3eab897797
// requires https://gist.github.com/toddzebert/b4465de41b0f8d317d7a685604983c36
var getAuth = asyncSim.bind(null, 'Authorized');
var getProfile = asyncSim.bind(null, 'Profile');
var getFeed = asyncSim.bind(null, function(data) {
for (var a = [], i = randInt(4, 2); i; i--) {
a.push(randInt(90, 1));
}
return a;
});
var getPost = function(post) {
return asyncSim.bind(null, function(data) {
posts[post] = post + 100;
return post + 100;
});
};
var getAd = (function() {
var i = 1;
return function () {
return asyncSim.bind(null, 'Ad#' + i++);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment