public static <T, D> Flux<T> usingWhen(Publisher<D> resourceSupplier,
			Function<? super D, ? extends Publisher<? extends T>> resourceClosure,
			Function<? super D, ? extends Publisher<?>> asyncComplete,
			Function<? super D, ? extends Publisher<?>> asyncError) {
		//null asyncCancel translates to using the `asyncComplete` function in the operator
		return onAssembly(new FluxUsingWhen<>(resourceSupplier, resourceClosure,
				asyncComplete, asyncError, null));
	}
public static <T, D> Flux<T> usingWhen(Publisher<D> resourceSupplier,
			Function<? super D, ? extends Publisher<? extends T>> resourceClosure,
			Function<? super D, ? extends Publisher<?>> asyncComplete,
			Function<? super D, ? extends Publisher<?>> asyncError) {
		
		return onAssembly(new FluxUsingWhen<>(resourceSupplier, resourceClosure,
				asyncComplete, asyncError, null));
	}
public static < T , D > Flux < T > usingWhen ( Publisher < D > resourceSupplier , Function < ? super D , ? extends Publisher < ? extends T > > resourceClosure , Function < ? super D , ? extends Publisher < ? > > asyncComplete , Function < ? super D , ? extends Publisher < ? > > asyncError ) { //null asyncCancel translates to using the `asyncComplete` function in the operator return onAssembly ( new FluxUsingWhen <> ( resourceSupplier , resourceClosure , asyncComplete , asyncError , null ) ) ; }
Uses a resource, generated by a {@link Publisher} for each individual {@link Subscriber},
while streaming the values from a {@link Publisher} derived from the same resource.
Whenever the resulting sequence terminates, the relevant {@link Function} generates
a "cleanup" {@link Publisher} that is invoked but doesn't change the content of the
main sequence. Instead it just defers the termination (unless it errors, in which case
the error suppresses the original termination signal).
<p>
<img class="marble" src="doc-files/marbles/usingWhenSuccessForFlux.svg" alt="">
<p>
Individual cleanups can also be associated with main sequence cancellation and
error terminations:
<p>
<img class="marble" src="doc-files/marbles/usingWhenFailureForFlux.svg" alt="">

<p>
Note that if the resource supplying {@link Publisher} emits more than one resource, the
subsequent resources are dropped ({@link Operators#onNextDropped(Object, Context)}). If
the publisher errors AFTER having emitted one resource, the error is also silently dropped
({@link Operators#onErrorDropped(Throwable, Context)}).
An empty completion or error without at least one onNext signal triggers a short-circuit
of the main sequence with the same terminal signal (no resource is established, no
cleanup is invoked).
<p>
Additionally, the terminal signal is replaced by any error that might have happened
in the terminating {@link Publisher}:
<p>
<img class="marble" src="doc-files/marbles/usingWhenCleanupErrorForFlux.svg" alt="">
<p>
Finally, early cancellations will cancel the resource supplying {@link Publisher}:
<p>
<img class="marble" src="doc-files/marbles/usingWhenEarlyCancelForFlux.svg" alt="">

@param resourceSupplier a {@link Publisher} that "generates" the resource,
subscribed for each subscription to the main sequence
@param resourceClosure a factory to derive a {@link Publisher} from the supplied resource
@param asyncComplete an asynchronous resource cleanup invoked if the resource closure terminates with onComplete or is cancelled
@param asyncError an asynchronous resource cleanup invoked if the resource closure terminates with onError
@param <T> the type of elements emitted by the resource closure, and thus the main sequence
@param <D> the type of the resource object
@return a new {@link Flux} built around a "transactional" resource, with several
termination path triggering asynchronous cleanup sequences
@see #usingWhen(Publisher, Function, Function, Function, Function)
Uses a resource generated by a { @link Publisher } for each individual { @link Subscriber } while streaming the values from a { @link Publisher } derived from the same resource . Whenever the resulting sequence terminates the relevant { @link Function } generates a cleanup { @link Publisher } that is invoked but doesn t change the content of the main sequence . Instead it just defers the termination ( unless it errors in which case the error suppresses the original termination signal ) . <p > <img class = marble src = doc - files / marbles / usingWhenSuccessForFlux . svg alt = > <p > Individual cleanups can also be associated with main sequence cancellation and error terminations : <p > <img class = marble src = doc - files / marbles / usingWhenFailureForFlux . svg alt = >