btford / btford/angular-phonegap-ready
Why not use a promise?
- Dominant language
- JavaScript
- Stars
- 95
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
I was using this and thought I should make it use a promise. I ended up with something like this.. it seems a lot better:
``` js
angular.module('btford.phonegap.ready', []).
factory('phonegapReady', function ($rootScope, $q) {
var loadingDeferred = $q.defer();
document.addEventListener('deviceready', function() {
$rootScope.$apply(loadingDeferred.resolve);
});
return function phonegapReady() {
return loadingDeferred.promise;
};
});
```
After phonegap is loaded, the promise always instantly resolves.
It's just used like this:
``` js
phonegapReady().then(function() {
doStuff();
}});
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the phonegapReady factory and its deviceready listener; compare the current API with the promise-based example in the issue. Verify that phonegapReady() returns a promise and that the promise resolves after deviceready, including when called after PhoneGap has loaded.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, javascript
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100