Skip to content

Commit ec2b96d

Browse files
author
Guillaume Chau
committed
perf(vuex): optimize autoload
1 parent 28efcaf commit ec2b96d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/app-frontend/src/views/vuex/VuexStateInspector.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ export default {
155155
'activeIndex',
156156
'inspectedIndex',
157157
'lastReceivedState',
158-
'inspectedModule'
158+
'inspectedModule',
159+
'history'
159160
]),
160161
161162
...mapGetters('vuex', [
@@ -311,16 +312,19 @@ export default {
311312
}
312313
}, 250),
313314
314-
loadState () {
315+
loadState: debounce(function () {
315316
const history = this.filteredHistory
316317
this.inspect(history[history.length - 1])
317-
},
318+
}, 300),
318319
319-
onMutation: debounce(function () {
320+
onMutation () {
320321
if (this.$shared.vuexAutoload) {
321-
this.loadState()
322+
const unwatch = this.$watch(() => this.history.length, (value, oldValue) => {
323+
unwatch()
324+
this.loadState()
325+
})
322326
}
323-
}, 300),
327+
},
324328
325329
onVuexInit () {
326330
if (this.$shared.vuexAutoload) {

0 commit comments

Comments
 (0)