Class Subscription<T extends Serializable>
java.lang.Object
co.yellowdog.platform.clients.serversentevents.Subscription<T>
- All Implemented Interfaces:
 SubscriptionEventListener<T>,AutoCloseable,EventListener
public class Subscription<T extends Serializable>
extends Object
implements AutoCloseable, SubscriptionEventListener<T>
Manages multiple listeners subscribing to the same logical instance of T (as opposed to specific object instance in memory).
- 
Method Summary
Modifier and TypeMethodDescriptionvoidclose()getId()voidjoin()static <T extends Serializable>
Subscription<T> subscribeTo(SubscriptionEventListener<T> listener, Function<SubscriptionEventListener<T>, CompletableFuture<?>> producer) voidInvoked if the server cancels the subscription associated with this listenervoidsubscriptionError(Throwable error) Invoked if an error occurs on the subscription associated with this listener.voidInvoked when an updated instance of the object is received from YellowDog Platform. 
- 
Method Details
- 
subscribeTo
public static <T extends Serializable> Subscription<T> subscribeTo(SubscriptionEventListener<T> listener, Function<SubscriptionEventListener<T>, CompletableFuture<?>> producer)  - 
close
public void close()- Specified by:
 closein interfaceAutoCloseable
 - 
join
public void join() - 
updated
Description copied from interface:SubscriptionEventListenerInvoked when an updated instance of the object is received from YellowDog Platform.- Specified by:
 updatedin interfaceSubscriptionEventListener<T extends Serializable>- Parameters:
 data- an updated instance of the object for which the listener was registered
 - 
subscriptionError
Description copied from interface:SubscriptionEventListenerInvoked if an error occurs on the subscription associated with this listener.- Specified by:
 subscriptionErrorin interfaceSubscriptionEventListener<T extends Serializable>- Parameters:
 error- the error that occurred
 - 
subscriptionCancelled
public void subscriptionCancelled()Description copied from interface:SubscriptionEventListenerInvoked if the server cancels the subscription associated with this listener- Specified by:
 subscriptionCancelledin interfaceSubscriptionEventListener<T extends Serializable>
 - 
getId
 
 -