I have a question about how Vuex reactivity is designed to work. I have the following store:
// state
state: {
database: {
tables: []
}
}
// mutator
ADD_TABLE(state, {table}) {
state.database.tables.push(table);
}
So when the ADD_TABLE
mutation happens vue components and the vuex watch react only when the object is directly changed and not reacting on nested property change.
// after the mutation happens
store.watch(state => state.database, change => console.log(change)) // this doesn't log
store.watch(state => state.database.tables, change => console.log(change)) // this does
Is this the desired behavior and why, or I have something breaking in my code?
{ deep: true }
as the third argument to your watcher and see if that works. – Stephan-v