Package dev.hilla
Class EndpointSubscription<TT>
- java.lang.Object
-
- dev.hilla.EndpointSubscription<TT>
-
public class EndpointSubscription<TT> extends Object
A subscription that wraps a Flux and allows to listen for unsubscribe events from the browser.An unsubscribe event is sent when "cancel" is called in the browser but also if the browser has disconnected from the server either explicitly or been disconnected from the server for a long enough time.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description reactor.core.publisher.Flux<TT>getFlux()Returns the flux value provide for this subscription.RunnablegetOnUnsubscribe()Returns the callback that is invoked when the browser unsubscribes from the subscription.static <T> EndpointSubscription<T>of(reactor.core.publisher.Flux<T> flux, Runnable onDisconnect)Creates a new endpoint subscription.
-
-
-
Method Detail
-
getFlux
public reactor.core.publisher.Flux<TT> getFlux()
Returns the flux value provide for this subscription.
-
getOnUnsubscribe
public Runnable getOnUnsubscribe()
Returns the callback that is invoked when the browser unsubscribes from the subscription.
-
of
public static <T> EndpointSubscription<T> of(reactor.core.publisher.Flux<T> flux, Runnable onDisconnect)
Creates a new endpoint subscription. A subscription wraps a flux that provides the values for the subscriber (browser) and a callback that is invoked when the browser unsubscribes from the subscription.- Type Parameters:
T- the type of data in the subscription- Parameters:
flux- the flux that produces the dataonDisconnect- a callback that is invoked when the browser unsubscribes- Returns:
- a subscription
-
-