Class MaybeConsumers


  • public final class MaybeConsumers
    extends Object
    Utility methods for creating and using consumers Maybes.
    Since:
    0.18.0
    • Method Detail

      • subscribeAutoDispose

        public static <T> Disposable subscribeAutoDispose​(Maybe<T> source,
                                                          CompositeDisposable composite,
                                                          Consumer<? super T> onSuccess)
        Wraps the given onXXX callbacks into a Disposable MaybeObserver, adds it to the given CompositeDisposable and ensures, that if the upstream completes or this particlular Disposable is disposed, the MaybeObserver is removed from the given composite.

        The MaybeObserver will be removed after the callback for the terminal event has been invoked.

        Type Parameters:
        T - the value type
        Parameters:
        source - the source Maybe to subscribe to.
        composite - the composite Disposable to add and remove the created Disposable MaybeObserver
        onSuccess - the callback for upstream items
        Returns:
        the Disposable that allows disposing the particular subscription.
      • subscribeAutoDispose

        public static <T> Disposable subscribeAutoDispose​(Maybe<T> source,
                                                          CompositeDisposable composite,
                                                          Consumer<? super T> onSuccess,
                                                          Consumer<? super Throwable> onError)
        Wraps the given onXXX callbacks into a Disposable MaybeObserver, adds it to the given CompositeDisposable and ensures, that if the upstream completes or this particlular Disposable is disposed, the MaybeObserver is removed from the given composite.

        The MaybeObserver will be removed after the callback for the terminal event has been invoked.

        Type Parameters:
        T - the value type
        Parameters:
        source - the source Maybe to subscribe to.
        composite - the composite Disposable to add and remove the created Disposable MaybeObserver
        onSuccess - the callback for upstream items
        onError - the callback for an upstream error if any
        Returns:
        the Disposable that allows disposing the particular subscription.
      • subscribeAutoDispose

        public static <T> Disposable subscribeAutoDispose​(Maybe<T> source,
                                                          CompositeDisposable composite,
                                                          Consumer<? super T> onSuccess,
                                                          Consumer<? super Throwable> onError,
                                                          Action onComplete)
        Wraps the given onXXX callbacks into a Disposable MaybeObserver, adds it to the given CompositeDisposable and ensures, that if the upstream completes or this particlular Disposable is disposed, the MaybeObserver is removed from the given composite.

        The MaybeObserver will be removed after the callback for the terminal event has been invoked.

        Type Parameters:
        T - the value type
        Parameters:
        source - the source Maybe to subscribe to.
        composite - the composite Disposable to add and remove the created Disposable MaybeObserver
        onSuccess - the callback for upstream items
        onError - the callback for an upstream error if any
        onComplete - the callback for the upstream completion if any
        Returns:
        the Disposable that allows disposing the particular subscription.