Skip to content

Commit 38fffb9

Browse files
fix(overmind-vue): handle running actions in mounted
1 parent 1e20df1 commit 38fffb9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/node_modules/overmind-vue/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ export default class VueApp<
9696
// a callback that runs whenever a mutation
9797
// matches the paths tracked on this component
9898
componentOptions.mounted = function() {
99-
const paths = instance.clearTrackState(this.__trackId)
99+
const vueInstance = this
100+
const paths = instance.clearTrackState(this.__trackId, () => {
101+
mounted && mounted.call(vueInstance)
102+
})
100103
instance.eventHub.emitAsync(EventType.COMPONENT_ADD, {
101104
componentId,
102105
componentInstanceId: this.__componentInstanceId,
@@ -130,7 +133,6 @@ export default class VueApp<
130133
paths: Array.from(paths),
131134
})
132135
}
133-
mounted && mounted.call(this)
134136
}
135137

136138
// When unmounting the component we dispose

packages/node_modules/overmind/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,8 @@ export default class App<
685685
trackState() {
686686
return this.proxyStateTree.startPathsTracking()
687687
}
688-
clearTrackState(id: number) {
689-
return this.proxyStateTree.clearPathsTracking(id)
688+
clearTrackState(id: number, cb?: () => void) {
689+
return this.proxyStateTree.clearPathsTracking(id, cb)
690690
}
691691
addMutationListener(paths, cb) {
692692
return this.proxyStateTree.addMutationListener(paths, cb)

0 commit comments

Comments
 (0)