Unable to process binding error when async observable disposes mid-update
0 reputation · 23 Jul 2020, 14:09 UTC
When a custom binding handler initiates asynchronous work (e.g., a throttled observable or a deferred extender), the developer must ensure that any pending notifications or timers are cancelled if the bound DOM node is removed by Knockout.
The framework offers ko.utils.domNodeDisposal.addDisposeCallback for cleanup, but it does not automatically dispose ko.computed or pureComputed instances created inside the handler, nor does it cancel pending rateLimit or deferred notifications.
This leaves an open decision about who should own the disposal of such async resources and what the recommended pattern is for guaranteeing cancellation without relying on manual try/catch or memory‑leak prone code.
Should Knockout automatically dispose computeds created in binding handlers when the node is removed? If not, what is the prescribed way to bind the lifetime of throttled/deferred observables to the DOM node lifecycle? How can developers reliably cancel pending deferred extender notifications associated with a binding?