Skip to content

Commit d3feb1f

Browse files
feat(proxy-state-tree): allow force flushing
1 parent c6ed5bc commit d3feb1f

File tree

1 file changed

+10
-0
lines changed
  • packages/node_modules/proxy-state-tree/src

1 file changed

+10
-0
lines changed

packages/node_modules/proxy-state-tree/src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ export class ProxyStateTree<T extends object> implements IProxyStateTree<T> {
138138
return () =>
139139
this.mutationCallbacks.splice(this.mutationCallbacks.indexOf(callback), 1)
140140
}
141+
forceFlush() {
142+
const emptyMutations = []
143+
const emptyPaths = new Set()
144+
for (let key in this.pathDependencies) {
145+
const callbacks = this.pathDependencies[key]
146+
callbacks.forEach((callback) => {
147+
callback(emptyMutations, emptyPaths, this.currentFlushId++, false)
148+
})
149+
}
150+
}
141151
flush(trees, isAsync: boolean = false) {
142152
let changes
143153
if (Array.isArray(trees)) {

0 commit comments

Comments
 (0)