mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 23:24:46 -04:00
use async and await (#62)
Use async and await instead of promise chains
This commit is contained in:
parent
11f01094b4
commit
a5af15b278
7 changed files with 92 additions and 80 deletions
|
@ -13,16 +13,19 @@ export const ApplicationLoader: React.FC<ApplicationLoaderProps> = ({children, i
|
|||
|
||||
useEffect(() => {
|
||||
setDoneTasks(0);
|
||||
initTasks.map(task =>
|
||||
task.then(() =>
|
||||
setDoneTasks(prevDoneTasks => {
|
||||
return prevDoneTasks + 1;
|
||||
}))
|
||||
.catch((reason) => {
|
||||
initTasks.forEach(task => {
|
||||
(async () => {
|
||||
try {
|
||||
await task;
|
||||
setDoneTasks(prevDoneTasks => {
|
||||
return prevDoneTasks + 1;
|
||||
})
|
||||
} catch (reason) {
|
||||
setFailed(true);
|
||||
console.error(reason);
|
||||
})
|
||||
)
|
||||
}
|
||||
})();
|
||||
})
|
||||
}, [initTasks]);
|
||||
|
||||
return (<Fragment>{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue