Interface Publisher<V>
-
- Type Parameters:
V
- The type of notification received by subscribers
- All Known Subinterfaces:
Processor<I,O>
,Processor.Iso<V>
,Processor.Transactional<I,O>
,Processor.TransactionalIso<V>
,Publisher.Cached<V>
,ValueReference<T>
public interface Publisher<V>
Something that can publish events.Each subscriber is responsible for removing itself from this stream, by using the Disposable returned upon subscription
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Publisher.Cached<V>
A publisher that caches the last value received
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Publisher.Cached<V>
cache()
Return a publisher that will track its most recent value.default Publisher.Cached<V>
cache(@Nullable V initialValue)
A cached publisher with an initial valuestatic <V,E extends Exception>
Publisher<V>execute(CheckedSupplier<V,E> action)
Execute an action returning a single value on the commonForkJoinPool
, and pass the result to any subscribers.static <V,E extends Exception>
Publisher<V>execute(CheckedSupplier<V,E> action, Executor executor)
Execute an action returning a single value on the providedExecutor
, and pass the result to any subscribers.Executor
getExecutor()
Get the executor that will be used to handle publishedboolean
hasSubscribers()
Return whether or not this Publisher has any subscribers.default <R> Publisher<R>
map(CheckedFunction<? super V,? extends R,TransactionFailedException> mapper)
Disposable
subscribe(Subscriber<? super V> subscriber)
Subscribe to updates from this Publisher.
-
-
-
Method Detail
-
execute
static <V,E extends Exception> Publisher<V> execute(CheckedSupplier<V,E> action)
Execute an action returning a single value on the commonForkJoinPool
, and pass the result to any subscribers. Subscribers who only begin subscribing after the operation has been completed will receive the result of the operation.- Type Parameters:
V
- returned value typeE
- exception thrown- Parameters:
action
- The action to perform- Returns:
- a publisher
-
execute
static <V,E extends Exception> Publisher<V> execute(CheckedSupplier<V,E> action, Executor executor)
Execute an action returning a single value on the providedExecutor
, and pass the result to any subscribers. Subscribers who only begin subscribing after the operation has been completed will receive the result of the operation.- Type Parameters:
V
- returned value typeE
- exception thrown- Parameters:
action
- The action to performexecutor
- The executor to perform this operation on- Returns:
- a publisher
-
subscribe
Disposable subscribe(Subscriber<? super V> subscriber)
Subscribe to updates from this Publisher. If this is already closed, the Subscriber will receive an error event with an IllegalStateException, and the returnedDisposable
will be a no-op.- Parameters:
subscriber
- The listener to register- Returns:
- A disposable that can be used to cancel this subscription
-
hasSubscribers
boolean hasSubscribers()
Return whether or not this Publisher has any subscribers.In a concurrent environment, this value could change from the time of calling.
- Returns:
- if there are subscribers
-
map
default <R> Publisher<R> map(CheckedFunction<? super V,? extends R,TransactionFailedException> mapper)
-
cache
default Publisher.Cached<V> cache()
Return a publisher that will track its most recent value. The provided processor won't have a value until one is submitted to its owning publisher.- Returns:
- A publisher based on this one
-
cache
default Publisher.Cached<V> cache(@Nullable V initialValue)
A cached publisher with an initial value- Parameters:
initialValue
- The value to- Returns:
- The
-
getExecutor
Executor getExecutor()
Get the executor that will be used to handle published- Returns:
- the executor
-
-