GithubHelp home page GithubHelp logo

milankinen / cljs-rx Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 300 KB

RxJS bindings for ClojureScript

License: MIT License

Clojure 2.62% JavaScript 97.38%
clojurescript clojure rxjs frp reactive-programming

cljs-rx's Introduction

cljs-rx

Complete RxJS 5 bindings for ClojureScript

Clojars Project

Example usage

(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 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.
(-> ...
    (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

cljs-rx's People

Contributors

milankinen avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

cljs-rx's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.