Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

new Observer API #110

Open
5 tasks
passsy opened this issue Jul 19, 2017 · 0 comments
Open
5 tasks

new Observer API #110

passsy opened this issue Jul 19, 2017 · 0 comments

Comments

@passsy
Copy link
Contributor

passsy commented Jul 19, 2017

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

  • We should change the API in a way observers receive distinct events for pre- and post lifecycle callbacks.
  • When a observer is added it should receive all previous events to the current lifecycle state as if it was added in the beginning.
  • Add events when the observer was added to a presenter or got removed to cleanup resources
  • add getPresenter() to get the current presenter the observer is attached to and it's state
  • like now, call destructing events in reversed order to the constructing events
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants