-
-
Save sonthonaxrk/9caee0ee2005c0398328 to your computer and use it in GitHub Desktop.
sequential-async-recusive-baconjs-queue.js
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
var pages = new Bacon.Bus(); | |
var next = $("#next").asEventStream('click').map(true); | |
var pageNo = 0; | |
pages.flatMapConcat(asyncFunction).zip(next).onValue(value => { | |
console.log(value); | |
pages.push(value); | |
}); | |
pages.push(1); | |
function asyncFunction(page) { | |
// Simulating something like an AJAX request | |
return Bacon.later(1000 + (Math.random() * 3000), Math.random() ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment