Simple event creation
Step 1. Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Step 2. Add the dependency
dependencies {
compile 'com.github.fcannizzaro:fast-event:1.0.0'
}
register event annotations.
emit event.
delete event.
define method to run.
run method on ui.
run method on a thread.
class Sample extends Activity {
@OnUi
@Event("my-event")
private void onUpdate(String key, Integer counter) {
// do something
}
@Async
@Event("my-event-on-thread")
private void onUpdate(String key) {
// do something
}
@Override
protected void onCreate(Bundle savedInstanceState) {
...
FastEvent.bind(this);
...
}
}
class Sample extends Fragment {
// define events
// ...
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
...
FastEvent.bind(this, getActivity());
...
}
}
FastEvent.emit("my-event", "fcannizzaro", 20);
MIT - Francesco Cannizzaro