Skip to content

operators: Add ref_count(other) operator overload.#485

Merged
kirkshoop merged 1 commit intoReactiveX:masterfrom
iam:fix-484
Mar 6, 2019
Merged

operators: Add ref_count(other) operator overload.#485
kirkshoop merged 1 commit intoReactiveX:masterfrom
iam:fix-484

Conversation

@iam
Copy link
Copy Markdown
Contributor

@iam iam commented Feb 15, 2019

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: #484

Copy link
Copy Markdown
Member

@kirkshoop kirkshoop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you! If you need help with the tests I am happy to work with you on them.

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: ReactiveX#484
@kirkshoop kirkshoop merged commit 8eddaa1 into ReactiveX:master Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants