It was never so easy to get YouTube subscribers
Get Free YouTube Subscribers, Views and Likes

Send Data from one component to multiple components in real time with Subject u0026 Observer in Angular

Follow
XAdmin

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 parentchild relationships
This approach is known as SubjectObserver pattern or also called as Publishsubscribe 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‬

posted by Sivokao