Skip to content Skip to sidebar Skip to footer

Is It Possible To Store Instances Of Custom Class In Vuex/(Vue Data)?

According to vue documentation, it is not possible to store anything besides plain objects. (https://ru.vuejs.org/v2/api/#data). I always use vuex as a DI container, I see it from

Solution 1:

You can absolutely store class instances in the store state.

I generally store arrays of models, which is really useful to keep logic in one place.

Something like:

Api.load('/api/users').then(res => commit('users', res.data.map(User.create)))

Post a Comment for "Is It Possible To Store Instances Of Custom Class In Vuex/(Vue Data)?"