项目作者: milankinen

项目描述 :
RxJS bindings for ClojureScript
高级语言: JavaScript
项目地址: git://github.com/milankinen/cljs-rx.git
创建时间: 2017-12-03T15:30:58Z
项目社区:https://github.com/milankinen/cljs-rx

开源协议:MIT License

下载


cljs-rx

Complete RxJS 5 bindings for ClojureScript

Clojars Project

Example usage

  1. (ns example.app
  2. (:require [cljs-rx.core :as rx]
  3. [cljs-rx.ajax :as ajax]))
  4. (-> (rx/interval 5000)
  5. (rx/switch-map (fn [_] (ajax/request {:url "/status" :method "GET" :response-type "json"}))
  6. (rx/map #(js->clj (:response %) :keywordize-keys true))
  7. (rx/filter identity)
  8. (rx/subscribe! {:next #(js/console.log %)
  9. :error #(js/console.error %)
  10. :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 IWatchables (= 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