/AutoRxBinder

Annotation processor to generate RxJava Func/Action bindings.

Primary LanguageJava

AutoRxBinder

Annotation processor to generate RxJava Func/Action bindings for java 6+.

Usage

Simply include AutoRxBinder in your project and annotate the methods you want to use in RxJava with @RxBind.

public class Foo {
    @RxBind
    public void hello(String name) {
        System.out.println("Hello, " + name + ".");
    }
}

Now you can use it like:

public void baz() {
    Foo foo = new Foo();
    Observable.just("world").subscribe(FooBindings.hello(foo));
}

Or better:

import static package.of.Foo.FooBindings.hello;
...
public void baz() {
    Foo foo = new Foo();
    Observable.just("world").subscribe(hello(foo));
}

###@Partial Annotate parameters you want to pass to Func/Action constructor with @Partial:

public class Foo {
    @RxBind
    public void greet(@Partial String niceThings, String name) {
        System.out.println(niceThings + ", " + name + ".");
    }
}

And use it like:

import static package.of.Foo.FooBindings.greet;
...
public void baz() {
    Foo foo = new Foo();
    Observable.just("sekai").subscribe(greet(foo, "Hello"));
}

##Setup In your module gradle dependencies:

apt 'com.github.moomoon:AutoRxBinder:0.1.3'
provided 'com.github.moomoon:AutoRxBinder:0.1.3'