Coder Social home page Coder Social logo

rxgwt's Introduction

RxGWT: Reactive Extensions for GWT

Maven Central Build Status Join the chat at https://gitter.im/intendia-oss/rxgwt

GWT specific bindings for RxJava (requires RxJava GWT).

This module adds the minimum classes to RxJava that make writing reactive components in GWT applications easy and hassle-free. More specifically, it provides adapters for all available events and various operators like bufferedFinally, debounceFinally, etc.

GWT module system requires all classes used by a module to be included as dependant modules. So to not to force to load all optional modules various independent small modules are exposed by RxGWT.

  • RxGWT.gwt.xml - includes common utils, usually not included explicit as it is included by all other modules
  • RxUser.gwt.xml - includes GWT user dependant utils like RxHandlers and RxEvents
  • RxElemental.gwt.xml - legacy GWT elemental utils
  • RxElemental2.gwt.xml - new generation GWT elemental2 utils
  • RxElemento.gwt.xml - elemento typed events on top of new generation GWT elemental2 utils

Download

Releases are deployed to the Central Repository.

Snapshots of the development version are available in Sonatype's snapshots repository.

Example

Observable<List<double[]>> mouseDiff$ = mouseMove(canvas)
        .map(e -> canvasPosition(canvas, e))
        .buffer(3, 1);

Observable<List<double[]>> mouseDrag$ = mouseDown(canvas).compose(log("mouse down"))
        .flatMap(e -> mouseDiff$.takeUntil(mouseUp(canvas).compose(log("mouse up"))));

Observable<List<double[]>> touchDiff$ = touchMove(canvas)
        .map(e -> e.getTouches().get(0))
        .map(e -> canvasPosition(canvas, e))
        .buffer(2, 1);

Observable<List<double[]>> touchDrag$ = touchStart(canvas).compose(log("touch down"))
        .flatMap(e -> touchDiff$.takeUntil(touchEnd(canvas).compose(log("touch up"))));

Observable<Object> down$ = merge(mouseDown(canvas), touchStart(canvas));
Observable<List<double[]>> drag$ = merge(mouseDrag$, touchDrag$);

Observable<String> paint$ = keyPress(canvas, '1').map(e -> "paint").startWith("default");
Observable<String> erase$ = keyPress(canvas, '2').map(e -> "erase");

All the mouseMove, mouseDown, touchMove, touchStart, touchEnd and keyPress static methods are exposed by the RxGWT API. To find all of them just explore RxGwt, or RxHandlers and RxEvents. RxEvents and RxHandlers are auto-generated using all classes in gwt-user extending from Events and HasValue respectively.

You can see this complete code example here RxCanvas, or other interesting one in RxSnake.

rxgwt's People

Contributors

ibaca avatar tdesjardins 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.