I am in the situation where I want to overwrite the set method that knockout has on observables; and to give you an example why I want that, take the following example code:
this.magic = ko.observableArray();
// ... inside an Ajax request
var formatted = reduceAndFormat(respone);
this.magic(formatted);
This is repeated a couple of times, so instead I would like to move the entire body of the reduceAndFormat function in the set method of a possibly customized observable.
Is there a way to do this? because outside of subscribing to observable updates didn’t see much else in the documentation.
You can create a writable computed observable
Something like this perhaps: