Port of meteor's transparent reactive framework for android
Java
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
gradle/wrapper
reactiveviews
reactor
.gitignore
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

Reactor

Port of meteor's transparent reactive framework for android

Meteor's tracker

Reactor docs

Tracker docs

Installation

Make sure you've got jcenter in your depdencies

allprojects {
    repositories {
        jcenter()
    }
}

add the following to your build.gradle depedencies group

    compile 'io.dwak:reactor:1.0'

How to use:

###Example

Field dependecies:

    //This wraps your variable in a reactive object
    private ReactorVar<String> mFavoriteFood = new ReactorVar<String>();

    public String getFavoriteFood() { 
        return mFavoriteFood.getValue(); // this binds the dependency
    }

    public void setFavoriteFood(String favoriteFood) {
        mFavoriteFood.setValue(favoriteFood); //this lets the ReactiveVar know the dep has changed
    }

Changing and reacting to property change:

    Reactor.getInstance().autoRun(new ReactorComputationFunction() {
        @Override
        public void react() {
            Log.d("TAG", getFavoriteFood());
        }
    });

    new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
        @Override
        public void run() {
            setFavoriteFood("MANGOES");
        }
    }, 1000);

with the above code block, you would see PIZZA in your logs, and in 1 second, would see MANGOES