Commit 9fbe1d8b authored by Simeon Anfinrud's avatar Simeon Anfinrud Committed by Commit Bot

[Chromecast] Erase param type of Observable.not().

This allows users of Observable.not() to avoid importing
org.chromium.chromecast.base.Unit, while communicating the same
intent that there is nothing special about the data.

This is also in anticipation of rewriting how not() works if
Observables that can have multiple activations at once are made.
For such Observables, a fold() or reduce() operator would be a
natural way to implement not(), and forcing the type signature
of the result of reduce() to agree with not() is an unnecessary
constraint, when all that matters for not() is the lifetime of
the activation, not the data type.

Bug: None
Test: cast_base_junit_tests, cast_shell_junit_tests
Change-Id: I89f6f40695f443d9c946abaad4d00a9faa463046
Reviewed-on: https://chromium-review.googlesource.com/1241849Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Commit-Queue: Simeon Anfinrud <sanfin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594388}
parent 25bf0d7d
......@@ -85,7 +85,7 @@ public abstract class Observable<T> {
/**
* Returns an Observable that is activated only when the given Observable is not activated.
*/
public static Observable<Unit> not(Observable<?> observable) {
public static Observable<?> not(Observable<?> observable) {
Controller<Unit> opposite = new Controller<>();
opposite.set(Unit.unit());
observable.subscribe(x -> {
......
......@@ -52,7 +52,7 @@ public class CastAudioManager {
*
* Observable<AudioFocusLoss> focusLoss = castAudioManager.requestFocusWhen(focusRequest);
* // Get an Observable of when focus is taken:
* Observable<Unit> gotFocus = Observable.not(focusLoss);
* Observable<?> gotFocus = Observable.not(focusLoss);
* // Get an Observable of when a specific request got focus:
* Observable<Both<CastAudioFocusRequest, AudioFocusLoss>> requestLost =
* focusRequest.andThen(focusLoss);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment