gertqin / vuex-class-modules

Typescript class decorators for vuex modules
MIT License
193 stars 20 forks source link

$watch should return unwatch function #23

Closed alsotang closed 5 years ago

alsotang commented 5 years ago

https://vuex.vuejs.org/api/#watch

To stop watching, call the returned unwatch function.

I call $watch in a component created, and wanna stop it when destroyed

alsotang commented 5 years ago

Now I can only use a condition var to exit the callback. But the watch is still running, not release.

alsotang commented 5 years ago

Wait some hours. I will write tests for this pr.

bodograumann commented 5 years ago

Maybe we should annotate the return type⁉

alsotang commented 5 years ago

yep. I will add return type

alsotang commented 5 years ago

ok. Tests and return type annotation are added.

bodograumann commented 5 years ago

Thanks for your contribution. Lgtm.

gertqin commented 5 years ago

Looks good! Thanks for the contribution.

alsotang commented 5 years ago

please publish a new version to npm. thank you