New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to log all state changes (not only actions or mutations) #1448

Open
Danilo-Araujo-Silva opened this Issue Nov 14, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@Danilo-Araujo-Silva

Danilo-Araujo-Silva commented Nov 14, 2018

What problem does this feature solve?

With these built-in logger plugin we are able to subscribe to our store and log all state mutations.

But, it looks like, for now, we are not able to log all state changes other than mutations or actions. What does it mean? For example, if we are controlling the state of the application drawer (like this one on the Vuetify project or more specifically some inline editing actions in the data table component) and we would like to connect (even mapping) the store state directly in the component we will not be able to log the mutations there, since there's no mutation action involved.

Maybe we could use events to try to accomplish that but I'll be far more difficult.

I think it could be very good for us we have the possibility to log state changes that are not triggered by mutations and actions too.

What does the proposed API look like?

const myPlugin = store => {
  // called when the store is initialized
  store.subscribe((state, mutation, action) => {
    // called after every state change and not only on mutations.
    // The mutation comes in the format of `{ type, payload }`.
  })
}
@leoyli

This comment has been minimized.

leoyli commented Nov 14, 2018

In practice, you should never mutate states out of store (mutations). You’d either copy it into local state (e.g. form), or commit a mutation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment