airbnb / RxGroups

Easily group RxJava Observables together and tie them to your Android Activity lifecycle
Apache License 2.0
693 stars 44 forks source link

ResubscriptionObserver in MVP #25

Closed meierjan closed 7 years ago

meierjan commented 7 years ago

Does the ResubscriptionObserver with @AutoResubscribe have to be inside the activity or can I put it somewhere else like into the Presenter?

I am injecting the GroupLifecycleManager into the presenter to use it and of course calling the life cycle methods inside the activity.

elihart commented 7 years ago

You can put it in any class, the Presenter would be a fine option.

You just have to make sure to call groupLifecycleManager.subscribe(presenter) so that the manager knows where to look for the @AutoResubscribe annotations and observers.

A pattern we use is to pass a manager to a helper class via its constructor, and then inside the class's constructor we save the manager to a field and do groupLifecycleManager.subscribe(this).

meierjan commented 7 years ago

Thank you for the fast reply. Maybe its a good idea to add this to the readme 👍 works like charm