We support async/await and promise natively, and the easiest way to do that is how you might do this in realworld code.
Say you have a synchronous function and you want to fire off a background task without caring for its result immediately.
Storing returned promises and handling them is not supported yet
To do this in JS environments, one might write code like this:
async-demo.ts
Copy
class Docker { readonly shouldCrash?: boolean; container() { if (this.shouldCrash) { return 'exiting with code 1'; } console.log('We are calling our sideCar without waiting for its result') this.sideCar('hello world!'); const result = this.db(); this.cache(); } db() { } cache() { } async sideCar(arg: string) { await this.wait(); console.log(`Logging: ${arg}`) } private async wait() { return new Promise<void>(resolve=>setTimeout(resolve, 5000)) }}