Get previous value of an observable in subscribe of same observable

ko.subscribable.fn.subscribeChanged = function (callback) { var oldValue; this.subscribe(function (_oldValue) { oldValue = _oldValue; }, this, ‘beforeChange’); this.subscribe(function (newValue) { callback(newValue, oldValue); }); }; Use the above like this: MyViewModel.MyObservableProperty.subscribeChanged(function (newValue, oldValue) { });

How to conditionally push an item in an observable array?

An observableArray exposes an indexOf function (wrapper to ko.utils.arrayIndexOf). This allows you to do: if (myObservableArray.indexOf(itemToAdd) < 0) { myObservableArray.push(itemToAdd); } If the two are not actually a reference to the same object and you want to run custom comparison logic, then you can use ko.utils.arrayFirst like: var match = ko.utils.arrayFirst(myObservableArray(), function(item) { return itemToAdd.id … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)