Empty, Error and Never overloads with type witness#654
Empty, Error and Never overloads with type witness#654akarnokd wants to merge 1 commit intoReactiveX:masterfrom
Conversation
|
RxJava-pull-requests #587 SUCCESS |
|
Is it necessary to have such overloads? I just think it's weird that passing an unused var. |
|
I think this witness trick is common in C#, but I've never seen it in Java, so I would not add these overloads. |
|
It depends on how many times you write the following pattern: import static rx.Observable.*;
concat(from(1,2,3), empty()); // incompatible types Object vs Integer in Java < 8
concat(from(1,2,3), empty(4));
concat(from(1,2,3), Observable.<Integer>empty());
merge(just(4), error(new Exception()); // incompatible types Object vs Integer in Java < 8
merge(just(4), error(new Exception(), 5);
merge(just(4), Observable.<Integer>error(new Exception()); |
|
Instead of adding overloads everywhere we have the Observable<String> s = Observable.empty().cast(String.class).take(1)
Observable<String> s = Observable.<String>empty().take(1);Even if we were to use the witness patter it would be better to take Observable<String> s = Observable.empty(String.class).take(1);This is equally elegant but requires overloads for all similar use cases. In .Net this is essential because you cannot write the type of an anonymous type (as per @headinthebox ) and this isn't a problem in Java. |
This commit adds support for adding tags to Retry, CircuitBreaker, Ratelimiter and Bulkhead functionality. These tags can then be used by other modules for example Prometheus, MicroMeter, etc.
Witness variants for #653.