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

Add manageViewSubscriptions and manageSubscriptions #43

Merged
merged 7 commits into from
Dec 15, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ public void onChange(final TiPresenter.State state,
}

/**
* Add your subscriptions here and they will automatically unsubscribed when {@link
* TiPresenter#destroy()} gets called
* Add your subscriptions here and they will automatically unsubscribed when
* {@link TiPresenter#destroy()} gets called
*
* @throws IllegalStateException when the presenter has reached {@link net.grandcentrix.thirtyinch.TiPresenter.State#DESTROYED}
* @see #manageSubscriptions(Subscription...)
*/
public void manageSubscription(@NonNull final Subscription subscription) {
if (mPresenterSubscriptions == null) {
Expand All @@ -71,12 +72,26 @@ public void manageSubscription(@NonNull final Subscription subscription) {
mPresenterSubscriptions.add(subscription);
}

/**
* Add your subscriptions here and they will automatically unsubscribed when
* {@link TiPresenter#destroy()} gets called
*
* @throws IllegalStateException when the presenter has reached {@link net.grandcentrix.thirtyinch.TiPresenter.State#DESTROYED}
* @see #manageSubscription(Subscription)
**/
public void manageSubscriptions(@NonNull final Subscription... subscriptions) {
for (final Subscription subscription : subscriptions) {
manageSubscription(subscription);
}
}

/**
* Add your subscriptions for View events to this method to get them automatically cleaned up
* in {@link TiPresenter#detachView()}. typically call this in {@link
* TiPresenter#attachView(TiView)} where you subscribe to the UI events.
*
* @throws IllegalStateException when no view is attached
* @see #manageViewSubscriptions(Subscription...)
*/
public void manageViewSubscription(@NonNull final Subscription subscription) {
if (mUiSubscriptions == null) {
Expand All @@ -85,4 +100,20 @@ public void manageViewSubscription(@NonNull final Subscription subscription) {
}
mUiSubscriptions.add(subscription);
}

/**
* Add your subscriptions for View events to this method to get them automatically cleaned up
* in {@link TiPresenter#detachView()}. typically call this in {@link
* TiPresenter#attachView(TiView)} where you subscribe to the UI events.
*
* @throws IllegalStateException when no view is attached
* @see #manageViewSubscription(Subscription)
*/
public void manageViewSubscriptions(@NonNull final Subscription... subscriptions) {
for (final Subscription subscription : subscriptions) {
manageViewSubscription(subscription);
}
}


}