Created
July 12, 2019 16:03
-
-
Save atishay/c9bba7671f63574faa04aae56eb2326d 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 saveWaiting = false; | |
| function delaySaveIfRunning(args, promise) { | |
| if ((promise instanceof Promise) ) { | |
| if (promise.state === 'pending') { | |
| if (!saveWaiting) { | |
| saveWaiting = true; | |
| promise.then(() => { | |
| saveWaiting = false; | |
| object.save.apply(object, args); | |
| }); | |
| } | |
| return true; | |
| } | |
| return false; | |
| } | |
| return false; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment