Skip to content

Instantly share code, notes, and snippets.

@rogeriochaves
Created April 30, 2015 13:21
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 rogeriochaves/146b46096ce23ebd6308 to your computer and use it in GitHub Desktop.
Save rogeriochaves/146b46096ce23ebd6308 to your computer and use it in GitHub Desktop.
Comparing RxJS on javascript and clojurescript
(ns rxjsclj.core
(:require [Rx]))
(defn stream-for [x]
(.map (.interval js/Rx.Observable 2000) x))
(def providers (.from js/Rx.Observable [1 2 3]))
(-> (stream-for providers)
(.concatMap #(.map % stream-for))
(.mergeAll)
(.forEach #(.log js/console (clj->js %))))
var Rx = require('rx');
var streamFor = function (x) {
return Rx.Observable.interval(2000).map(function () {
return x;
});
}
var providers = Rx.Observable.from([1, 2, 3]);
streamFor(providers).concatMap(function (providers) {
return providers.map(function (provider) {
return streamFor(provider);
});
}).mergeAll().forEach(function (data) {
console.log(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment