T - the Type to which each response body part is transformed to.
Created by Karel Maesen, Geovise BVBA on 19/12/14.public class CollectingSubscriber<T> extends rx.Subscriber<ServerResponseElement>
Subscriber that collects all parts of a response body, after transformation, into a List.
CollectingSubscribers are definitely not thread-safe
| Constructor and Description |
|---|
CollectingSubscriber(java.util.function.Function<byte[],T> transformPart)
Constructs an instance
|
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.Future<java.util.List<T>> |
collect()
Returns the future list of response parts, after transformation
|
java.util.List<T> |
collectImmediately()
Unsubscribes from the observer and returns the items already received.
|
void |
onCompleted()
Notifies the Observer that the
Observable has finished sending push-based notifications. |
void |
onError(java.lang.Throwable e)
Notifies the Observer that the
Observable has experienced an error condition. |
void |
onNext(ServerResponseElement serverResponseElement)
Provides the Observer with a new item to observe.
|
public CollectingSubscriber(java.util.function.Function<byte[],T> transformPart)
transformPart - the function that transforms the bytes of each response part into an object of type Tpublic void onCompleted()
Observable has finished sending push-based notifications.
The Observable will not call this method if it calls onError(java.lang.Throwable).
public void onError(java.lang.Throwable e)
Observable has experienced an error condition.
If the Observable calls this method, it will not thereafter call onNext(be.wegenenverkeer.rxhttp.ServerResponseElement) or
onCompleted().
e - the exception encountered by the Observablepublic void onNext(ServerResponseElement serverResponseElement)
The Observable may call this method 0 or more times.
The Observable will not call this method again after it calls either onCompleted() or
onError(java.lang.Throwable).
serverResponseElement - the item emitted by the Observablepublic java.util.List<T> collectImmediately()
public java.util.concurrent.Future<java.util.List<T>> collect()