Skip to content

Commit

Permalink
perf(vuex): optimize autoload
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Oct 29, 2019
1 parent 28efcaf commit ec2b96d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/app-frontend/src/views/vuex/VuexStateInspector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ export default {
'activeIndex',
'inspectedIndex',
'lastReceivedState',
'inspectedModule'
'inspectedModule',
'history'
]),
...mapGetters('vuex', [
Expand Down Expand Up @@ -311,16 +312,19 @@ export default {
}
}, 250),
loadState () {
loadState: debounce(function () {
const history = this.filteredHistory
this.inspect(history[history.length - 1])
},
}, 300),
onMutation: debounce(function () {
onMutation () {
if (this.$shared.vuexAutoload) {
this.loadState()
const unwatch = this.$watch(() => this.history.length, (value, oldValue) => {
unwatch()
this.loadState()
})
}
}, 300),
},
onVuexInit () {
if (this.$shared.vuexAutoload) {
Expand Down

0 comments on commit ec2b96d

Please sign in to comment.