Created
April 30, 2015 13:21
-
-
Save rogeriochaves/146b46096ce23ebd6308 to your computer and use it in GitHub Desktop.
Comparing RxJS on javascript and clojurescript
This file contains 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
(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 %)))) |
This file contains 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 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