vue-class-store icon indicating copy to clipboard operation
vue-class-store copied to clipboard

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

Open thecodewarrior opened this issue 2 years ago • 1 comments

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.

thecodewarrior avatar Dec 07 '21 21:12 thecodewarrior

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)

nebaughman avatar Dec 08 '21 16:12 nebaughman