Port of meteor's transparent reactive framework for android
Meteor's tracker
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'
###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