Looking for analog of RxJs ofObjectChanges method in Angular 2

I want to create class property decorator which will look for all changes of this property and do some stuff. How can i do that?

In RxJs i found ofObjectChanges method https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/ofobjectchanges.md

but looks like that method does not exist in angular2 RxJs version.

That method must trigger on changes of object, for example with Array.push();

Upvotes: 7

Views: 1236

Answers (1)

Alexander Leonov
Alexander Leonov

Reputation: 4794

You're right, there's no (yet?) implementation of that method in RxJs 5 beta currently used in Angular 2: Migrating from RxJs 4 to 5. But it is not actually clear if you really need it.

If you use typescript then you can see about writing decorators here. Also, you can look into angular's sources, kind of starting point is modules/@angular/core/src/metadata/directives.ts. You can see how angular team implemented @Input() decorator and figure out how to do it in your case which sounds pretty similar to me.

Upvotes: 1

Related Questions