Skip to content

Instantly share code, notes, and snippets.

@chiro-hiro
Created July 24, 2020 15:24
Show Gist options
  • Save chiro-hiro/e08ed4bde1bb396c84fa3cf2f09baeb6 to your computer and use it in GitHub Desktop.
Save chiro-hiro/e08ed4bde1bb396c84fa3cf2f09baeb6 to your computer and use it in GitHub Desktop.
Trick for mixing betwen async and callback
function test(callback: (result: any)=>void) {
(async () => {
const a = await function1();
const b = await function2();
return { a, b };
})()
.then((result) => {
callback(result);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment