Skip to content

Commit

Permalink
docs(subject.md): clarify that refCount is an operator (#4774)
Browse files Browse the repository at this point in the history
Clarify that refCount is an operator and not a method used directly on a ConnectableObservable.

Closes #4664
  • Loading branch information
natmegs authored and benlesh committed Jun 5, 2019
1 parent 68d5128 commit e4f2d23
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/subject.md
Expand Up @@ -150,7 +150,7 @@ setTimeout(() => {
}, 2000);
```

If we wish to avoid explicit calls to `connect()`, we can use ConnectableObservable's `refCount()` method (reference counting), which returns an Observable that keeps track of how many subscribers it has. When the number of subscribers increases from `0` to `1`, it will call `connect()` for us, which starts the shared execution. Only when the number of subscribers decreases from `1` to `0` will it be fully unsubscribed, stopping further execution.
If we wish to avoid explicit calls to `connect()`, we can use the `refCount()` operator (reference counting), which returns an Observable from a ConnectableObservable and keeps track of how many subscribers it has. When the number of subscribers increases from `0` to `1`, it will call `connect()` for us, which starts the shared execution. Only when the number of subscribers decreases from `1` to `0` will it be fully unsubscribed, stopping further execution.

<span class="informal">`refCount` makes the multicasted Observable automatically start executing when the first subscriber arrives, and stop executing when the last subscriber leaves.</span>

Expand Down Expand Up @@ -202,7 +202,7 @@ setTimeout(() => {
// observerB unsubscribed
```

The `refCount()` method only exists on ConnectableObservable, and it returns an `Observable`, not another ConnectableObservable.
The `refCount()` operator is only available to use on ConnectableObservable, and it returns an `Observable`, not another ConnectableObservable.

## BehaviorSubject

Expand Down

0 comments on commit e4f2d23

Please sign in to comment.