Java Code Examples for rx.subscriptions.Subscriptions#create()
The following examples show how to use
rx.subscriptions.Subscriptions#create() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BroadcastRegisterOnSubscribe.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@Override public void call(final Subscriber<? super Intent> subscriber) { final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (!subscriber.isUnsubscribed()) { subscriber.onNext(intent); } } }; final Subscription subscription = Subscriptions.create(new Action0() { @Override public void call() { context.unregisterReceiver(broadcastReceiver); } }); subscriber.add(subscription); context.registerReceiver(broadcastReceiver, intentFilter, broadcastPermission, schedulerHandler); }
Example 2
Source File: CenterTitleSideButtonBar.java From HandyWidgets with MIT License | 6 votes |
private Subscription unsubscribeInUiThread(final Action0 unsubscribe) { return Subscriptions.create(new Action0() { @Override public void call() { if (Looper.getMainLooper() == Looper.myLooper()) { unsubscribe.call(); } else { final Scheduler.Worker inner = AndroidSchedulers.mainThread().createWorker(); inner.schedule(new Action0() { @Override public void call() { unsubscribe.call(); inner.unsubscribe(); } }); } } }); }
Example 3
Source File: OnSubscribeBroadcastRegister.java From rxnetwork-android with Apache License 2.0 | 6 votes |
@Override public void call(final Subscriber<? super Intent> subscriber) { final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { subscriber.onNext(intent); } }; final Subscription subscription = Subscriptions.create(new Action0() { @Override public void call() { context.unregisterReceiver(broadcastReceiver); } }); subscriber.add(subscription); context.registerReceiver(broadcastReceiver, intentFilter, broadcastPermission, schedulerHandler); }
Example 4
Source File: BroadcastObservable.java From RxSerach with Apache License 2.0 | 6 votes |
private static Subscription unsubscribeInUiThread(final Action0 unsubscribe) { return Subscriptions.create(new Action0() { @Override public void call() { if (Looper.getMainLooper() == Looper.myLooper()) { unsubscribe.call(); } else { final Scheduler.Worker inner = AndroidSchedulers.mainThread().createWorker(); inner.schedule(new Action0() { @Override public void call() { unsubscribe.call(); inner.unsubscribe(); } }); } } }); }
Example 5
Source File: AndroidSubscriptions.java From u2020-mvp with Apache License 2.0 | 5 votes |
/** * Create a {@link Subscription} that always runs the specified {@code unsubscribe} on the * UI thread. */ public static Subscription unsubscribeInUiThread(final Action0 unsubscribe) { return Subscriptions.create(() -> { if (Looper.getMainLooper() == Looper.myLooper()) { unsubscribe.call(); } else { final Scheduler.Worker inner = AndroidSchedulers.mainThread().createWorker(); inner.schedule(() -> { unsubscribe.call(); inner.unsubscribe(); }); } }); }
Example 6
Source File: QueryUpdateOnSubscribe.java From rxjava-jdbc with Apache License 2.0 | 5 votes |
private Subscription createUnsubscriptionAction(final State state) { return Subscriptions.create(new Action0() { @Override public void call() { close(state); } }); }
Example 7
Source File: EmitterWithMultipleSubscriptions.java From titus-control-plane with Apache License 2.0 | 4 votes |
public EmitterWithMultipleSubscriptions(Emitter<T> delegate) { this.actual = delegate; this.delegate = new SerializedObserver<>(delegate); Subscription composedSubscription = Subscriptions.create(() -> subscriptions.forEach(Subscription::unsubscribe)); actual.setSubscription(composedSubscription); }