I have a form with a text input bound to computed property (containing a time). After a user enters a value, it is parsed into a integer value containing the total minutes.
Since this is not a trivial function (there are many ways of formatting time), the property has a Throttle Extender.
This all works fine, the problem is when the user enters a value and immediately hits a save button, obviously the throttled value is not evaluated yet.
self.totalMinutes = ko.observable(0);
self.totalMinutesValue = ko.computed({
read: function() {
return MinutesToFormat(self.totalMinutes());
}
write: function(value) {
self.totalMinutes(FormatToMinutes(value));
}
}).extend({ throttle: 250 });
self.Save = function() {
// Send self.totalMinutes() to server, need to ensure the throttled
// computed has been written.
}
Is there a simple way to force the property to update immediately from the send method? I could add a setTimeout
but that is of course far from ideal.