remy / bind.js

bind.js - simple two way data binding to HTML and callbacks
694 stars 62 forks source link

Cleanup method so event listeners are all cleared #19

Open northkode opened 8 years ago

northkode commented 8 years ago

Would be nice to have a bind.cleanup() so that there isn't left over event listeners lying around.

remy commented 8 years ago

Isn't this solved by exporting the object?

On Sat, 2 Jan 2016 15:58 northkode notifications@github.com wrote:

Would be nice to have a bindcleanup() so that there isn't left over event listeners lying around

— Reply to this email directly or view it on GitHub https://github.com/remy/bind.js/issues/19.

northkode commented 8 years ago

Not that I can see.. Your export just makes sure the getter setters aren't there so you hqve a vanilla object to use, but it doesn't call any removeEventListener on any Dom or input item, that had been created on binding. Thefore even if you export, those Dom items can never be released from memory and will just eventually clog up an app. Especially a mobile hybrid one.

remy commented 8 years ago

Ah ha. You're absolutely right. Hmm...yeah, it should have an unbind methods then too. Good shout.

Do you want to have a go at a PR for this?