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
I tried to find this out on my own for the last couple of hours but either I am blind or stupid.
The way I understand RxJS you can create an Observable and subscribe() to it. Inside the brackets there is the actual Observer which defines what happens, when the Observable emits a value with defined functions (next(), error(), complete()). Also, the link between the Observable and the Observer gets saved via Subscription which is the return value of the subscribe() function.
Now my question: How does the Subscription know of which Observable it is part of? Like when unsubscribe() is called the link between Observable and Observer gets destroyed - but how does the Subscription know the link? I would expect some reference/pointer somewhere. But if I look into the definition of the Subscription class I can only find a teardown ( -> https://github.com/ReactiveX/rxjs/blob/7.1.0/src/internal/Subscription.ts#L5-L199 ). But what exactly is that? How does it work? Is it a reference to the original .subscribe() function? Or does it include a reference to the Observable?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I tried to find this out on my own for the last couple of hours but either I am blind or stupid.
The way I understand RxJS you can create an Observable and subscribe() to it. Inside the brackets there is the actual Observer which defines what happens, when the Observable emits a value with defined functions (next(), error(), complete()). Also, the link between the Observable and the Observer gets saved via Subscription which is the return value of the subscribe() function.
Now my question: How does the Subscription know of which Observable it is part of? Like when unsubscribe() is called the link between Observable and Observer gets destroyed - but how does the Subscription know the link? I would expect some reference/pointer somewhere. But if I look into the definition of the Subscription class I can only find a
teardown
( -> https://github.com/ReactiveX/rxjs/blob/7.1.0/src/internal/Subscription.ts#L5-L199 ). But what exactly is that? How does it work? Is it a reference to the original .subscribe() function? Or does it include a reference to the Observable?Beta Was this translation helpful? Give feedback.
All reactions