rxtodo | Playing around with RxJS and Cycle.js | Reactive Programming library
kandi X-RAY | rxtodo Summary
kandi X-RAY | rxtodo Summary
Playing around with RxJS and Cycle.js
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of rxtodo
rxtodo Key Features
rxtodo Examples and Code Snippets
Community Discussions
Trending Discussions on rxtodo
QUESTION
If you are essentially having the same question and your context is Angular you may want to read all the comments in the answer for more context.
Short version of this questionWhen doing let observe$ = someReplaySubject.asObservable()
, are we no longer required to unsubscribe from observe$
? In other words can we call let observe$ = someReplaySubject.asObservable()
from multiple Angular component instances and not worry about the connection from the notify
instance to the corresponding Observable
?
If we have a ReplaySubject
instance (Lets call it rxTodo
and we subscribe to it from Angular components by doing:
let todoObs$:Observable = rxTodo$.asObservable()
then even if the component is destroyed the todoObs$
references created in each component will dangle until the component itself is destroyed.
I'm attempting a Store
API for Angular and I have a replay subject that broadcasts changes to slices of the store. Here is the method that allows subscriptions to happen (The notifyCount tracks subscriptions, so that if there are none we don't bother with notification):
ANSWER
Answered 2018-Sep-03 at 17:12I think you are confusing unsubscribing from Subscription
and from Subject
.
What is actually recommended in Angular is unsubscribing from any open Subscription
when the component gets destroyed. A Subscription
is returned from Observable.subscribe
. When it gets unsubscribed, it doesn't receive values from the source observable anymore, which is what you want in most cases.
Unsubscribing from Subject
has a different effect. It switches the Subject into a closed
state where you can no longer call next
or subscribe to it. You can look directly at the source code to understand whats going on.
Unsubscribing from an Observable
is not possible, that's in part why you get the error.
In order to follow the recommendation, you should either make a list of all Subscriptions, that is, adding each Subscription to a list that you can access later, like that:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install rxtodo
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page