1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-28 15:34:20 +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)|*}
*/
export default function goToOnSuccess(func, history, destination) {
return (...args) => {
return async (...args) => {
let result
try {
console.debug("Provando ad eseguire: ", func)
result = func(...args)
console.debug("Executing: ", func)
result = await func(...args)
console.debug("Executed successfully: ", func, " moving to a different page.")
history.push(destination)
return result
}
catch(e) {
console.debug("Esecuzione fallita: ", func, ", non ha fatto nulla.")
console.debug("Execution failed: ", func, ", not doing anything.")
throw e
}
}