GCX-HCI / ThirtyInch

a MVP library for Android favoring a stateful Presenter
Apache License 2.0
1.03k stars 101 forks source link

new Observer API #110

Open passsy opened 7 years ago

passsy commented 7 years ago

Our TiLifecycleObserver API is great an maybe the best feature of ThirtyInch. It allows everyone to add functionality to TiPresenters. We use it for our rx implementation and the proposed Renderer uses it, too.

Implementing a TiLifecycleObserver is hard because the callbacks has a state and a boolean indicating if the method was called before or after the state callback was called. Worst case scenario: You initialize things twice but only expected the initialization once.

Right now it is required to add a TiLifecycleObserver right after initializing the TiPresenter. If you add it later you won't receive previous emitted events. The TiLifecycleObserver also never receives the created event because there is no way to add the observer before getting it.

And without passing in the Presenter in the constructor it is impossible to know the current presenter state.

Also missing is a callback when the observer is added and removed from a presenter. Cleanup is currently hard/impossible.

TODOs