Hi! Thanks for super work - so nice to se WebAPIs utilized in this way!
Situation:
I'm working in a webpage, where elements appear and disappear based on state.
Currently intl-number-input only binds events, but it has no destroy/unbind/teardown method, meaning there is no way to do garbage collection/free up memory.
Solution:
Add a .destroy method removing the instance and all listeners. Example API:
const numberInput = new NumberInput({
el: document.querySelector('input'),
options: {
// see API reference
}
})
// set initial value
numberInput.setValue(1234)
// Remove listeners and other references so element can be garbage collected
numberInput.destroy()
Hi! Thanks for super work - so nice to se WebAPIs utilized in this way!
Situation: I'm working in a webpage, where elements appear and disappear based on state. Currently intl-number-input only binds events, but it has no destroy/unbind/teardown method, meaning there is no way to do garbage collection/free up memory.
Solution: Add a
.destroy
method removing the instance and all listeners. Example API: