Class SyEventConsumer<T>
java.lang.Object
com.io7m.jsycamore.api.events.SyEventConsumer<T>
- Type Parameters:
T- The type of events
- All Implemented Interfaces:
Flow.Subscriber<T>
A simple implementation of the
Flow.Subscriber interface that exposes
a lambda-based API.-
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidonSubscribe(Flow.Subscription newSubscription) static <T> SyEventConsumer<T> subscribe(Flow.Publisher<T> publisher, Consumer<T> consumer) Subscribe to the given publisher, delivering events toconsumer(automatically requesting new events each time one is published), and callingonCompletewhen the publisher is closed.static <T> SyEventConsumer<T> subscribe(Flow.Publisher<T> publisher, Consumer<T> consumer, Runnable onComplete) Subscribe to the given publisher, delivering events toconsumer(automatically requesting new events each time one is published), and callingonCompletewhen the publisher is closed.
-
Method Details
-
subscribe
public static <T> SyEventConsumer<T> subscribe(Flow.Publisher<T> publisher, Consumer<T> consumer, Runnable onComplete) Subscribe to the given publisher, delivering events toconsumer(automatically requesting new events each time one is published), and callingonCompletewhen the publisher is closed.- Type Parameters:
T- The type of events- Parameters:
publisher- The publisherconsumer- An event consumeronComplete- A function called on closing the publisher- Returns:
- A consumer
-
subscribe
Subscribe to the given publisher, delivering events toconsumer(automatically requesting new events each time one is published), and callingonCompletewhen the publisher is closed.- Type Parameters:
T- The type of events- Parameters:
publisher- The publisherconsumer- An event consumer- Returns:
- A consumer
-
onSubscribe
- Specified by:
onSubscribein interfaceFlow.Subscriber<T>
-
onNext
- Specified by:
onNextin interfaceFlow.Subscriber<T>
-
onError
- Specified by:
onErrorin interfaceFlow.Subscriber<T>
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceFlow.Subscriber<T>
-