https://github.com/milankinen/cljs-rx
RxJS bindings for ClojureScript
https://github.com/milankinen/cljs-rx
clojure clojurescript frp reactive-programming rxjs
Last synced: 6 months ago
JSON representation
RxJS bindings for ClojureScript
- Host: GitHub
- URL: https://github.com/milankinen/cljs-rx
- Owner: milankinen
- License: mit
- Created: 2017-12-03T15:30:58.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-10T22:43:06.000Z (about 8 years ago)
- Last Synced: 2025-04-11T00:06:24.724Z (8 months ago)
- Topics: clojure, clojurescript, frp, reactive-programming, rxjs
- Language: JavaScript
- Homepage:
- Size: 293 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cljs-rx
Complete RxJS 5 bindings for ClojureScript
[](https://clojars.org/milankinen/cljs-rx)
## Example usage
```clj
(ns example.app
(:require [cljs-rx.core :as rx]
[cljs-rx.ajax :as ajax]))
(-> (rx/interval 5000)
(rx/switch-map (fn [_] (ajax/request {:url "/status" :method "GET" :response-type "json"}))
(rx/map #(js->clj (:response %) :keywordize-keys true))
(rx/filter identity)
(rx/subscribe! {:next #(js/console.log %)
:error #(js/console.error %)
:complete #(js/console.log "complete")}))
```
## Available namespaces
#### `cljs-rx.core`
Core functions and factories
#### `cljs-rx.ajax`
Observable AJAX functions
#### `cljs-rx.scheduler`
RxJS schedulers
#### `cljs-rx.subject`
Subjects and related functions
## Differences to JS version
* `rx/from` accepts ClojureScript sequences and `IWatchable`s (= Atoms)
* Every object satisfying either `Fn` or `IFn` can be used with operators in
addition to normal JS functions, e.g. `(rx/filter obs #{:lol :bal})`
* Operator functions (e.g. predicates and transform functions) receive only the
mapped/tested values. If you need to access event indexes as well, use `:all-args`
meta flag, e.g.
```clj
(-> ...
(rx/map (fn [x i] (+ x i))) ; ATTENTION! i == undefined
...)
(-> ...
(rx/map ^:all-args (fn [x i] (+ x i))) ; now works
...)
```
## License
* Bindings: MIT
* RxJS: Apache 2.0