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 TypeMethodDescriptionvoid
close()
getId()
void
join()
static <T extends Serializable>
Subscription<T> subscribeTo
(SubscriptionEventListener<T> listener, Function<SubscriptionEventListener<T>, CompletableFuture<?>> producer) void
Invoked if the server cancels the subscription associated with this listenervoid
subscriptionError
(Throwable error) Invoked if an error occurs on the subscription associated with this listener.void
Invoked 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:
close
in interfaceAutoCloseable
-
join
public void join() -
updated
Description copied from interface:SubscriptionEventListener
Invoked when an updated instance of the object is received from YellowDog Platform.- Specified by:
updated
in interfaceSubscriptionEventListener<T extends Serializable>
- Parameters:
data
- an updated instance of the object for which the listener was registered
-
subscriptionError
Description copied from interface:SubscriptionEventListener
Invoked if an error occurs on the subscription associated with this listener.- Specified by:
subscriptionError
in interfaceSubscriptionEventListener<T extends Serializable>
- Parameters:
error
- the error that occurred
-
subscriptionCancelled
public void subscriptionCancelled()Description copied from interface:SubscriptionEventListener
Invoked if the server cancels the subscription associated with this listener- Specified by:
subscriptionCancelled
in interfaceSubscriptionEventListener<T extends Serializable>
-
getId
-