Code Monkey home page Code Monkey logo

rxscala-js's Introduction

RxScala.js Build Status Scala.js Gitter Maven Central

This is a Scala adapter to RxJs.

Example usage:

val o = Observable.interval(200).take(5)
o.subscribe(n => println("n = " + n))
Observable.just(1, 2, 3, 4).reduce(_ + _)

Example usage in Browser:

Observable.fromEvent(document.getElementById("btn"),"click")
  .mapTo(1)
  .scan(0)(_ + _)
  .subscribe(n => println(s"Clicked $n times"))

Getting Started

Add the following to your sbt build definition:

libraryDependencies += "com.github.lukajcb" %%% "rxscala-js" % "0.14.1"

then import the types from the package rxscalajs.

Javascript Dependencies

RxScala.js doesn't actually come bundled with the underlying rx.js file, so you'll need to either add them manually or specify them as jsDependencies:

jsDependencies += "org.webjars.npm" % "rxjs" % "5.4.0" / "bundles/Rx.min.js" commonJSName "Rx"

Differences from RxJS

Similary to RxScala, this wrapper attempts to expose an API which is as Scala-idiomatic as possible. Some examples:

 // instead of concat:
def ++[U >: T](that: Observable[U]): Observable[U]

// curried in Scala collections, so curry fold also here:
def foldLeft[R](seed: R)(accumulator: (R, T) => R): Observable[R] 

// called skip in RxJS, but drop in Scala
def drop(n: Int): Observable[T] 

// like in the collection API
def zipWithIndex: Observable[(T, Int)] 

// the implicit evidence argument ensures that switch can only be called on Observables of Observables:
def switch[U](implicit evidence: Observable[T] <:< Observable[Observable[U]]): Observable[U]

Documentation

RxScala.js:

  • The API documentation can be found here.

RxJs:

If you're new to Rx, I suggest starting with this interactive tutorial.

Samples

Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.

LICENSE

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

rxscala-js's People

Contributors

kadekm avatar lukajcb avatar mchunkytrunk avatar olafurpg avatar

Watchers

 avatar  avatar

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.