Interface WriteStream<T>
-
- Type Parameters:
T
- the type of item emitted.
public interface WriteStream<T>
The write end of a data stream.Users of a write stream must not call any of the methods of this interface concurrently. That is, write streams are not thread safe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
complete()
Signals that the stream has completed and that no more items (or errors) are to come.void
error(Throwable throwable)
Signals a stream error.void
item(T item)
Emit an item.default <O> WriteStream<O>
itemMap(Subscription subscription, Action<? super O> itemMapper)
Creates a new write stream that passes error and complete signals on to this stream, but passes items to the given action.
-
-
-
Method Detail
-
item
void item(T item)
Emit an item.- Parameters:
item
- the item to emit
-
error
void error(Throwable throwable)
Signals a stream error.No other methods should be called on this stream after calling this method. It is not necessary to enforce this on user provided implementations of write streams as this is managed internally.
- Parameters:
throwable
- the error
-
complete
void complete()
Signals that the stream has completed and that no more items (or errors) are to come.No other methods should be called on this stream after calling this method. It is not necessary to enforce this on user provided implementations of write streams as this is managed internally.
-
itemMap
default <O> WriteStream<O> itemMap(Subscription subscription, Action<? super O> itemMapper)
Creates a new write stream that passes error and complete signals on to this stream, but passes items to the given action.This effectively creates an upstream write stream that transforms items. It is often useful when
Streams.streamMap(Publisher, StreamMapper)
mapping streams}.The
itemMapper
typically manually callsitem(Object)
on this stream, one or more times, when receiving an item. That is, the action may emit multiple items downstream in a particular invocation. If the mapper throws an exception, the exception will be emitted viaerror(Throwable)
and the subscription will be cancelled. The mapper may callcomplete()
orerror(Throwable)
, but should ensure that it does not call any other methods of this interface after.- Type Parameters:
O
- the type of item received by the returned write stream- Parameters:
subscription
- the upstream subscriptionitemMapper
- the item mapper- Returns:
- a write stream that writes through to this write stream
- Since:
- 1.4
-
-