I don't have much experience with RxJS, but I was wondering if there is a way to subscribe to an object property change? I am using RxJS 5. I use a BehaviorSubject to push new values to subscribers. The subject contains an object which defines some application settings.
So, what I want to do is, I want an application component to subscribe and get a new value when a specific property changes. Alternatively, I would like the observable to produce a copy of the object for each subscriber - so they don't have a reference to the original object.
My question is similar to this one.
The service that provides application settings:
app.factory('settingsProvider', ['$rootScope', function ($rootScope) {
let subject = new Rx.BehaviorSubject();
let updateSettings = function (obj) {
subject.next(_.merge({}, subject.getValue(), obj));
};
return {
updateSettings: updateSettings,
getObservable: function () {
return subject.asObservable();
}
};
}]);
In some directive, I would than like to subscribe to a change to some property. I currently have this:
let settings = {};
let settingsSubscription = settingsProvider.getObservable().subscribe(x => settings = x);