Package dev.hilla

Class 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 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 data
        onDisconnect - a callback that is invoked when the browser unsubscribes
        Returns:
        a subscription