1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-28 23:44:19 +00:00

🐛 Fix race condition

This commit is contained in:
Steffo 2021-05-17 15:48:27 +02:00
parent c13e5fff40
commit 5e3ef20785
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -7,16 +7,17 @@
* @returns {(function(): void)|*} * @returns {(function(): void)|*}
*/ */
export default function goToOnSuccess(func, history, destination) { export default function goToOnSuccess(func, history, destination) {
return (...args) => { return async (...args) => {
let result let result
try { try {
console.debug("Provando ad eseguire: ", func) console.debug("Executing: ", func)
result = func(...args) result = await func(...args)
console.debug("Executed successfully: ", func, " moving to a different page.")
history.push(destination) history.push(destination)
return result return result
} }
catch(e) { catch(e) {
console.debug("Esecuzione fallita: ", func, ", non ha fatto nulla.") console.debug("Execution failed: ", func, ", not doing anything.")
throw e throw e
} }
} }