While examining some code, I stumbled upon the following snippet:
this.busy = this.service.getInfo().subscribe((info: InfoData[]) => {
this.setInfo(info);
});
The property busy
is defined within a component and of type boolean
, it serves as an input value for the [ngBusy]
directive. The subscribe()
method returns a Subscription
object, which is not null and therefore cast to true
. This action triggers the directive to display a modal loading popup, which disappears once the info is resolved. Hence, at that point, when this.busy
becomes false, it indicates that the Subscription
object no longer exists.
Within the getInfo()
method, there is only one line: return Observable.of(info)
, where 'info' is a temporary variable.
Therefore, my query is:
Is the Subscription
automatically deleted after the data is resolved? If so, does this behavior apply only to Observable.of()
, or are there other instances of such behavior?