Move all code that executes after the switches to a new function

If any switches are async, the subsequent code will execute before
the switches are finished. This commit moves all that code to a new
function, and debounces the calls to onSwitch() so it only executes
once, after all the switches finish.

Fizes #72.
This commit is contained in:
Behind The Math
2018-01-20 22:06:03 -05:00
parent ca61c4a840
commit cb0a7cd850
3 changed files with 77 additions and 51 deletions

View File

@@ -24,6 +24,9 @@ module.exports = function(switches, switchesOptions, selectors, fromEl, toEl, op
if (this.log) {
this.log("newEl", newEl, "oldEl", oldEl)
}
this.state.numPendingSwitches++
if (switches[selector]) {
switches[selector].bind(this)(oldEl, newEl, options, switchesOptions[selector])
}