Created
June 15, 2018 14:39
-
-
Save cbonnissent/d3c5f67ca25b1e03939aee99bfa68164 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let syncReturnPromise = null; | |
let resolveReturn = null; | |
let actionSave = []; | |
syncReturn(Vue, $store, apiResponse, action = false) => { | |
if(action){ | |
actionSave.push(action); | |
} | |
if (syncReturnPromise !== null) { | |
resolveReturn(Vue, $store, apiResponse); | |
return syncReturnPromise; | |
} | |
return syncReturnPromise = new Promise((resolve, reject) => { | |
resolveReturn = debounce((Vue, $store, apiResponse) => { | |
resolveReturn = null; | |
syncReturnPromise = null; | |
_syncReturn(Vue, $store, apiResponse, actionSave).then(resolve).catch(reject); | |
actionSave = []; | |
}, 500); | |
resolveReturn(Vue, $store, apiResponse); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment