Skip to content

Instantly share code, notes, and snippets.

@dncrht
Last active February 6, 2016 09:40
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 dncrht/a04ab20c4931efac02bb to your computer and use it in GitHub Desktop.
Save dncrht/a04ab20c4931efac02bb to your computer and use it in GitHub Desktop.
RxJS and Bacon.js equivalences

RxJS and Bacon.js equivalences:

Bacon.js RxJS
Create stream for keyup events from an element var inputText$ = $([data-js=my-input]).asEventStream('keyup').map('.target.value'); var inputText$ = Rx.Observable.fromEvent($('[data-js=my-input]'), 'keyup').pluck('target', 'value')
Create stream for keyup events from a live element var inputText$ = $(document).asEventStream('keyup', '[data-js=my-input]').map('.target.value'); var inputText$ = Rx.Observable.create(function(observer) {$(document).on('keyup', '[data-js=my-input]', function(e) {observer.onNext(e.target.value);});});
Subscribe to a stream inputText$.onValue(function(props) {…}); inputText$.subscribe(function(props) {…});
Create stream from promises Bacon.fromPromise($.get(url, {text: text})); Rx.Observable.fromPromise($.get(url, {text: text}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment