I'm looking at this article about async/await
. It contains the following:
Sometimes, you only want to trigger an asynchronous computation and are not interested in when it is finished. The following code is an example:
async function asyncFunc() { const writer = openFile('someFile.txt'); writer.write('hello'); // don’t wait writer.write('world'); // don’t wait await writer.close(); // wait for file to close }
I'm interested in how the function proceeds if there is no await
for asynchronous functions calls insdide in this particular case. So can somebody please rewrite the above example using promises so I can better understand what's going on?
EDIT
As I understand, it can be rewritten like this:
async function asyncFunc() {
const writer = openFile('someFile.txt');
writer.write('hello'); // don’t wait
writer.write('world'); // don’t wait
return writer.close().then(()=>{
});
}
Thanks