Skip to content

Instantly share code, notes, and snippets.

@mindwing
Created June 8, 2016 05:05
Show Gist options
  • Save mindwing/7a312ff0287c79945eb5f25bf9d277be to your computer and use it in GitHub Desktop.
Save mindwing/7a312ff0287c79945eb5f25bf9d277be to your computer and use it in GitHub Desktop.
Agera Explained - 02.Observables and updatables
public class MyUpdatableActivity extends Activity implements Updatable {
private Observable observable;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
observable = new MyObservable();
}
@Override
public void update() {
// Act on the event
}
@Override
protected void onResume() {
super.onResume();
observable.addUpdatable(this);
update();
}
@Override
protected void onPause() {
super.onPause();
observable.removeUpdatable(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment