fast-event

Additional

Language
Java
Version
1.0.0 (May 13, 2017)
Created
May 25, 2016
Updated
May 13, 2017
Owner
Francesco Saverio Cannizzaro (fcannizzaro)
Contributor
Francesco Saverio Cannizzaro (fcannizzaro)
1
Activity
Badge
Generate
Download
Source code
APK file

Advertisement

fast-event

Simple event creation

How to include

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'
}

Static Methods

bind(Class clazz, [, Activity activity])

register event annotations.

emit(event, Object ... args)

emit event.

delete(event)

delete event.

Annotations

@Event(String: event)

define method to run.

@OnUi

run method on ui.

@Async

run method on a thread.

Usage

Activity / Service / Class

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);
        ...
    }
    
}

Fragment

class Sample extends Fragment {

    // define events
    // ...
    
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        ...
        FastEvent.bind(this, getActivity());
        ...
    }
    
}

Emit

 FastEvent.emit("my-event", "fcannizzaro", 20);

License

MIT - Francesco Cannizzaro