markForCheck? Scenario: @Input changed and component has not been refreshed.
markForCheck() and others in your components. This can be a great solution if you need full control over change detection. For instance, if you're getting data from a
websocketyou may want to use
detectChanges() to limit how often you're checking for changes. If you don't need full control, however, it can certainly over-complicate things.
There's an Observable field in a component, it got subscribed to. Can you spot a memory leak? (it should be unsubscribed from in
Subscription: represents the execution of an Observable, is primarily useful for cancelling the execution.
Observables. The pattern seems to almost dictate that
Subscriptionsare simply a “viewership” to the source and not something that controls the source. This is mostly because of the different types of Observables that we come to use and our inability to always know what type an observable is and what really happens when you do
subscribeyou are essentially just starting to listen. Similarly when you
unsubscribeyou are stopping your listening. Following is a classic example of a hot observable.
The observable is already working and streaming data. A realworld example might be when you enter in a life-stream movie, the movie is already streaming no matters if you are subscribed or not. Example,
subscribe. Similarly, the observer ends the underlying operation for that observer with an
unsubscribe. Most creation operators create a cold observable.
The observable does not stream data to the subscriptor until such is subscribed. A realworld example might be if you visit Netflix and start a movie, the movie will be displayed when you "subscribe" to it.
behaviorsubjectworks in angular?
In addition, you can get an observable from behavior subject using the