vue-class-store
vue-class-store copied to clipboard
beforeCreate/created lifecycle hooks aren't called (Vue 2 direct injection)
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.
It would be very helpful to have a created() hook method in @VueStore classes:
- The constructor is not appropriate in some cases (as mentioned above)
- Using
created()has more symmetry with TypeScript Vue component classes (at least in Vue 2)