In this video, we are going to discuss the approach to tranfer the data from one component to multiple components in real time with Subject and Observer in Angular application
Sharing Data via Service & Subject
This approach is commonly used for communication between components when they are not directly related by parent-child relationships
This approach is known as Subject-Observer pattern or also called as Publish-subscribe pattern
Service component : Acts as a centralized place to manage data communication between components using Subject for sending data and Observable for receiving data .
Important Notes:-
Observable Nature: Subject is both an Observable and an Observer. It can emit values (next(data)) and be subscribed to (getData() returns an Observable).
Subscription: Components or services that want to receive the emitted data should subscribe to getData(). It's important to unsubscribe from this Observable to prevent memory leaks, typically done in the ngOnDestroy lifecycle hook.
Multicasting: Subject allows multicasting, meaning it broadcasts the same data to multiple subscribers. This makes it useful for scenarios where multiple parts of your application need to react to the same events or data changes.
#angulardevelopment #angular17 @xadmin
Watch video Send Data from one component to multiple components in real time with Subject & Observer in Angular online without registration, duration hours minute second in high quality. This video was added by user XAdmin 29 June 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 87 once and liked it 3 people.