I'm implementing a byte message deserializer, which would dispatch deserialized messages on a dispatcher interface and return an observable of all Throwable
s thrown, so that client code can handle the errors.
A sketch of the prototype of the method doing that:
Observable<Throwable> dispatchDeserializedMessages(Observable<byte[]>, Dispatcher)
Now as of recent I am familiar with Subject<T, R>
, which would fit here perfectly, e.g.
Subject<byte[], Throwable> dispatchDeserializedMessages(Dispatcher)
But there are no convenience methods like create()
which could easily delegate to an observer and an observable. All concrete implementations unify T
with R
, so there's no way I could use one of those.
So my concrete question: Is there a way I can instantiate a suitable Subject<byte[], Throwable>
which delegates to an Observer
and Observable
? Is there any other way I can create such a Subject
without having to implement (in the sense of having to delegate each implemented method by hand) the whole of Subject
, Observable
and Observer
?