Commit 671e288a authored by Igor Murashkin's avatar Igor Murashkin
Browse files

operators: Add ref_count(other) operator overload.

The existing `connectable_observable.ref_count()` operator calls
connect on the source when it's subscribed to.

Generalize this by allowing an optional parameter `other`, i.e.
`observable.ref_count(connectable_observable other)` to be used as the
connect target.

Useful for implementing diamond graphs while retaining composability:

```
     A
   /   \
  B     C
   \   /
     D
     |
     E

auto A = ... | publish();
auto B = A | ...;
auto C = A | ...;
auto D = B | merge(C) | ref_count(A);
auto E = D | ...;

E | subscribe(...);
```

Resolves: https://github.com/ReactiveX/RxCpp/issues/484
Pull request: https://github.com/ReactiveX/RxCpp/pull/485

(Need to merge this into AOSP now because it's blocking an android
change).

(cherry picked from commit 77a5b21ac18d4e42a8402176a9b3baf583b7414e)

Change-Id: I9139dbce2c3b0ba4f4ca59b8300d2b4ceaef4855
parent bf1edc83
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment