filrak / vue-offline

Offline states and storage for Vue PWA
MIT License
349 stars 20 forks source link

Removing events #2

Closed josteph closed 6 years ago

josteph commented 6 years ago

Hi there, thanks for the plugin. But it's better to remove events by using beforeDestroy hook. Here is more or less what it should be:

mounted() {
    window.addEventListener('online', this.updateStatus)
    window.addEventListener('offline', this.updateStatus)
},
beforeDestroy() {
    window.removeEventListener('online', this.updateStatus)
    window.removeEventListener('offline', this.updateStatus)
},
methods: {
    updateStatus() {
        // do network change code here.
    }
}
filrak commented 6 years ago

Good point, do you want to propose PR with this (idea is yours) or you want me to do it?

josteph commented 6 years ago

I have never done any PR actually :) so I'm not sure how to do it. You can close this issue after adding the feature.

Thank you.

filrak commented 6 years ago

Ok, I'll do it this weekend (unfortunetly had no time in the previous one), thanks ;)