Is there a way to write a funcion with async/await native?

83 Views Asked by At

I need to write a function that uses native async/await in Angular.

Example:

var function = () => {
    var _self = {};

    _self.test = async () => {
        return await someAsyncFunc();
    }

    return _self;
}

When I do ng build --prod the configuration optimizes it and uses zone.js and catch async/await to handle the changes.

Is there a way to avoid this?

Dirty solutions:

  1. Make it a string with `` for example.

  2. Declare some vars and then .toString() and replace with correct syntax before executing it. (Actually in use)

Anyone have a better/clean solution?

Thanks

0

There are 0 best solutions below