Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to destroy/unbind/teardown #18

Closed
eirikbacker opened this issue Apr 9, 2023 · 1 comment · Fixed by #19
Closed

Add ability to destroy/unbind/teardown #18

eirikbacker opened this issue Apr 9, 2023 · 1 comment · Fixed by #19

Comments

@eirikbacker
Copy link

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()
@dm4t2
Copy link
Owner

dm4t2 commented Apr 14, 2023

Hi, thanks for your feedback!

I will look into it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants