Make jQuery Deferred / Promises and AngularJS $ q Deferred / Promises compatible

I have old JavaScript libraries that use jQuery promises as return objects from function calls. Now I am using AngularJS , which uses the $ q service (inspired by the Q library ). Does anyone have common JavaScript code to make these two different promise implementations compatible, so that jQuery promises can be used as if it were $ q promises? Or something similar?

+6
source share
1 answer

Third party promises can be wrapped $q.when(thirdPartyPromise) to convert to $ q promises. When thirdPartyPromise resolved, the promise of $ q is resolved and $scope.$apply() called.

+21
source

Source: https://habr.com/ru/post/954393/


All Articles