You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/rxjs.dev/content/guide/subject.md
+12-8Lines changed: 12 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,14 +71,16 @@ A "multicasted Observable" passes notifications through a Subject which may have
71
71
72
72
<spanclass="informal">A multicasted Observable uses a Subject under the hood to make multiple Observers see the same Observable execution.</span>
73
73
74
-
Under the hood, this is how the `multicast` operator works: Observers subscribe to an underlying Subject, and the Subject subscribes to the source Observable. The following example is similar to the previous example which used `observable.subscribe(subject)`:
74
+
Under the hood, this is how the `connectable` operator works: Observers subscribe to an underlying Subject, and the Subject subscribes to the source Observable. The following example is similar to the previous example which used `observable.subscribe(subject)`:
// These are, under the hood, `subject.subscribe({...})`:
84
86
multicasted.subscribe({
@@ -92,7 +94,7 @@ multicasted.subscribe({
92
94
multicasted.connect();
93
95
```
94
96
95
-
`multicast` returns an Observable that looks like a normal Observable, but works like a Subject when it comes to subscribing. `multicast` returns a `ConnectableObservable`, which is simply an Observable with the `connect()` method.
97
+
`connectable` returns an Observable that looks like a normal Observable, but works like a Subject when it comes to subscribing. `connectable` returns a `ConnectableObservable`, which is simply an Observable with the `connect()` method.
96
98
97
99
The `connect()` method is important to determine exactly when the shared Observable execution will start. Because `connect()` does `source.subscribe(subject)` under the hood, `connect()` returns a Subscription, which you can unsubscribe from in order to cancel the shared Observable execution.
98
100
@@ -116,11 +118,13 @@ Consider the following example where subscriptions occur as outlined by this lis
116
118
To achieve that with explicit calls to `connect()`, we write the following code:
0 commit comments