Skip to content

Instantly share code, notes, and snippets.

@gonaumov
Last active August 2, 2017 13:07
Show Gist options
  • Save gonaumov/e209b82ae2bccd0a4da4e6bdbac83e4b to your computer and use it in GitHub Desktop.
Save gonaumov/e209b82ae2bccd0a4da4e6bdbac83e4b to your computer and use it in GitHub Desktop.
task queue mechanism
this.streamOne = Bacon.fromBinder(function (sink) {
sink(new Bacon.Next());
}).filter(function () {
return sessionStorage.getItem('somethingExist') !== null && sessionStorage.getItem('somethingExist') === 'true';
}).toProperty();
// I noticed that it not works at all when I missed this
// The question is why? :(
this.streamOne.onValue(function () {
sessionStorage.removeItem('somethingExist');
});
this.streamTwo = new Bacon.Bus();
this.streamTwo.filter(function () {
// there is condition here ..
return true;
}).flatMapConcat(function (task) {
return self.streamOne.take(1).map(task);
}).onValue(function (data) {
console.log('do something');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment