Typescript async/await and angular $q service

后端 未结 3 602
孤城傲影
孤城傲影 2021-02-05 08:51

New TypeScript async/await feature uses ES6 promises. AngularJS uses $q service promises with slightly different interface.

Is there any way to use TypeScri

3条回答
  •  猫巷女王i
    2021-02-05 09:00

    I do not think you will be able to use them directly. But it should be quite easy to convert q promise into a++ promise, something like this:

    function Convert(qPromise): Promise 
    {
        return new Promise((resolve, reject) =>
        {
            qPromise.then((result: T) => resolve(result), (e) => reject(e));
        });
    };
    

提交回复
热议问题