davestewart / vue-class-store

Universal Vue stores you write once and use anywhere
https://github.com/davestewart/vue-class-store-demos
MIT License
277 stars 13 forks source link

beforeCreate/created lifecycle hooks aren't called (Vue 2 direct injection) #33

Open thecodewarrior opened 2 years ago

thecodewarrior commented 2 years ago

As it is in #27 the created lifecycle hook isn't called. That's because that has to be present directly on the options object, and I don't explicitly add support for that. My thought is to go a route similar to vue-class-component where it just calls a method called created().

This isn't as much of an issue in Vue 3, since the object is reactive from the very beginning. In Vue 2 you can't do any vue/reactive operations (e.g. this.$watch) inside the constructor, which is why having a created lifecycle hook is useful.

nebaughman commented 2 years ago

It would be very helpful to have a created() hook method in @VueStore classes: