I have a Knockout view model which contains a computed observable that simply filters some raw data based on the contents of a textual input. This computed observable is then bound to a table to display the information.
Each time the computed observable is calculated, I need to have a function run which updates some event listeners on the table rows (I have this function already).
However, I have been unable to fathom how to get it to run after the computed observable has updated. Placing a call to the function within the observable function does it before the new value is returned so actions it with legacy data. I have also considered extender syntax, but believe this to be an inappropriate solution.
If anyone has a solution or any pointers, I would greatly appreciate it.
UPDATE WITH CODE:
var viewModel = function(data) {
var self = this;
self.search = ko.observable('');
self.rawData = ko.observableArray(data);
self.filterData = ko.computed(function() {
return self.rawData().filter(function(item) {
var filter = self.search().toLowerCase();
return item.employeeNumber.toString().includes(filter) || item.name.toLowerCase().includes(filter) || filter == "";
});
});
};
Async function creates a new view model with the returned data and applies the bindings.
function reevaluateHandlers() {
// Code that should run every time the computed observable is calculated (filterData)
}