Class MaybeUsing<T,​D>

  • Type Parameters:
    T - the value type
    D - the resource type
    All Implemented Interfaces:
    MaybeSource<T>

    public final class MaybeUsing<T,​D>
    extends Maybe<T>
    Creates a resource and a dependent Maybe for each incoming Observer and optionally disposes the resource eagerly (before the terminal event is send out).
    • Field Detail

      • resourceSupplier

        final Supplier<? extends D> resourceSupplier
      • resourceDisposer

        final Consumer<? super D> resourceDisposer
      • eager

        final boolean eager
    • Constructor Detail

      • MaybeUsing

        public MaybeUsing​(Supplier<? extends D> resourceSupplier,
                          Function<? super D,​? extends MaybeSource<? extends T>> sourceSupplier,
                          Consumer<? super D> resourceDisposer,
                          boolean eager)
    • Method Detail

      • subscribeActual

        protected void subscribeActual​(MaybeObserver<? super T> observer)
        Description copied from class: Maybe
        Implement this method in subclasses to handle the incoming MaybeObservers.

        There is no need to call any of the plugin hooks on the current Maybe instance or the MaybeObserver; all hooks and basic safeguards have been applied by Maybe.subscribe(MaybeObserver) before this method gets called.

        Specified by:
        subscribeActual in class Maybe<T>
        Parameters:
        observer - the MaybeObserver to handle, not null