feat: onComplete config option (#4322)

* feat: `onComplete` config option

* tests(e2e): add case for onComplete option
This commit is contained in:
kyle
2018-03-16 00:08:39 -07:00
committed by GitHub
parent b0be261ef8
commit 624a81201f
7 changed files with 167 additions and 3 deletions

View File

@@ -0,0 +1,28 @@
let engaged = false
export default function() {
return {
statePlugins: {
spec: {
wrapActions: {
updateSpec: (ori) => (...args) => {
engaged = true
return ori(...args)
},
updateJsonSpec: (ori, system) => (...args) => {
const cb = system.getConfigs().onComplete
if(engaged && typeof cb === "function") {
// call `onComplete` on next tick, which allows React to
// reconcile the DOM before we notify the user
setTimeout(cb, 0)
engaged = false
}
return ori(...args)
}
}
}
}
}
}