Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Expose qFactory to enable a custom $q with a $scope-independent nextTick() #2993

Closed
mgcrea opened this issue Jun 17, 2013 · 2 comments
Closed

Comments

@mgcrea
Copy link
Contributor

mgcrea commented Jun 17, 2013

I'm having a hard time solving $q promises not correctly resolving out of AngularJS, in my case bridging back from Cordova/PhoneGap in a service.

  • Using the $rootScope.$apply won't work, I hit the $digest already in progress as I need several stacked calls when the app boot up (GoogleAnalytics init, PushNotifications, Udid retrieval, etc.). (actual code: https://github.com/mgcrea/angular-cordova/blob/master/src/angular-cordova.js#L37)
  • $rootScope.$evalAsync won't work, promise is never resolved.
  • Using $timeout works but is clearly suboptimal as it slows the bridge & triggers useless repaints.

It looks like several people encountered the same "broken promises" issue. Thus the idea of being able to define a custom $q that would behave more like the real $q for out of scope (usually in-services) operations.

@btford
Copy link
Contributor

btford commented Aug 24, 2013

As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.

Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.

Thanks!

@anemitoff
Copy link

I am using 1.2.0-rc1 and the issue still persists (why wouldn't it).

I have been twice bitten in the last week by the same thing when I resolved a promise outside of a $digest and ended up having my app hang because the then() clauses waiting on the promise were never called. The problem is that people who are familiar with Q in other contexts could never imagine that the then() clauses would not be resolved! Somehow there should at least be some error produced if next tick is not called within some reasonable period of time after resolve or reject are triggered. Perhaps this would even be a "debug" only check?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants