Skip to content

Instantly share code, notes, and snippets.

@MaartenS
Last active March 4, 2016 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaartenS/de0fd3a2c61da1cf220b to your computer and use it in GitHub Desktop.
Save MaartenS/de0fd3a2c61da1cf220b to your computer and use it in GitHub Desktop.

Otto eventbus

post an event

BusProvider.getInstance().post(new FooEvent());

subscribe to an event

@Override
public void onResume() {
    super.onResume();
    BusProvider.getInstance().register(this);
}

@Override
public void onPause() {
    super.onPause();
    BusProvider.getInstance().unregister(this);
}

@Subscribe
public void onFooEvent(FooEvent event) {
    // do stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment