Question: What is the best way to update the value of an Observable from within its subscription using Knockout and Typescript?
I am currently in the process of refactoring some old Knockout code to use Typescript. While going through the code, I came across a section where an observable is being subscribed to and updated with "this", which is not compatible with Typescript.
let utils = new Utils();
utils.subscribeFilterAlphanumeric = function(val){
var newVal = utils.filterAlphanumeric(val);
this(newVal);
// In regular JavaScript, "this" refers to the observable
// In Typescript, "this" references the Class "Utils"
};
myObservable = ko.observable();
myObservable.subscribe(utils.subscribeFilterAlphanumeric , myObservable);
Do you have any suggestions on how to make this functionality work in Typescript?
Thank you for your help!