How detect a object change in component

Hi All,

I have a property in my component, like I say : loggedUser.

I want to detected loggedUser value changed or not in one place. if changed I will trigger something.

I know it is not related with Ionic, it is Angular things, but just want to know how to do this, thanks a lot.

Observables are the best kind of friend you could hope for in this case. They’ll do exactly what you’re asking, and best of all you can unsubscribe from them whenever you want.

You’ll find lots of good stuff there

You can also look into RxJS’ documentation but its heavy stuff if you’re just getting into Observables. The angular docs are probably a better fit right now.

EventEmitters (@Output) are also a possible solution, though generally those are meant for parent child communication, I guess its possible they could be used within one component.

1 Like