Created
July 24, 2020 15:24
-
-
Save chiro-hiro/e08ed4bde1bb396c84fa3cf2f09baeb6 to your computer and use it in GitHub Desktop.
Trick for mixing betwen async and callback
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
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