Ali
Ali

Reputation: 1759

Is it wrong to use Subject observables to share data between parent and child components?

I usually use @Input/@Output directives to share data between components with parent/child relationship. But I can also use observables like BehaviorSubject to subscribe and listen to observers, so I am confused if I should use obserbvales when I can use @Input and @Output directives.

Upvotes: 0

Views: 390

Answers (1)

DeborahK
DeborahK

Reputation: 60558

It depends on the design patterns you prefer to follow.

If you follow a presentational/container component architecture, then you'll want to stick to @Input and @Output.

If you want to go with a declarative/reactive approach, then using Observables makes sense.

Upvotes: 2

Related Questions