Comments (12)
It needs a Promise library according to the offical Promise/A+ spec.
I'll update documentation to be more precise and give you an example. Hold on!
from cordova-app-loader.
According to the documentation of $q, angular is compatible with the ES6 specification on MDN.
Seeing the example, it does everything I need:
// for the purpose of this example let's assume that variables `$q` and `okToGreet`
// are available in the current lexical scope (they could have been injected or passed in).
function asyncGreet(name) {
// perform some asynchronous operation, resolve or reject the promise when appropriate.
return $q(function(resolve, reject) {
setTimeout(function() {
if (okToGreet(name)) {
resolve('Hello, ' + name + '!');
} else {
reject('Greeting ' + name + ' is not allowed.');
}
}, 1000);
});
}
var promise = asyncGreet('Robin Hood');
promise.then(function(greeting) {
alert('Success: ' + greeting);
}, function(reason) {
alert('Failed: ' + reason);
});
$q.all([asyncGreet('Mark'),asyncGreet('Lyle').then(function(names) {
console.log('We are '+names.join(' and '));
});
So you should be able to pass $q
and have it work! Can you check if this is true?
from cordova-app-loader.
I tried passing $q, but it does not work.
Here is the error that occurs:
deviceready = new Promise(function(resolve,reject){ (Object is not a function)
from cordova-app-loader.
Ok, I'll check that out!
from cordova-app-loader.
Fixed (7e6e87c)! Can you confirm? (Please use file from the repo - I haven't published to NPM or Bower yet).
I was using Promise.resolve(...)
in CordovaPromiseFS which isn't part of the official spec.
You can run the CordovaAppLoader demo and then point the manifest to: http://data.madebymark.nl/cordova-app-loader/issues/angular-q/manifest.json
. You should see a popup with "OK" before it reverts to factory default. You can check out the angular example here.
from cordova-app-loader.
This still doesn't work just by passing $q to the Promise parameter. new $q()
is not going to work (which is where it fails).
from cordova-app-loader.
Actually, the specification they claim to be following also uses new
. I have tried it with this example, and it works fine. Are you sure? (Can you give me code to reproduce the error?)
from cordova-app-loader.
I've continued to try this, but passing $q to the function does not work (at least it does not in angular 1.3).
Does not work:
// Initialize a FileSystem
var fs = new CordovaPromiseFS({
Promise: $q
});
Fails with:
deviceready = new Promise(function(resolve,reject){ (Object is not a function)
from cordova-app-loader.
Are you sure you're using Angular 1.3? I know that Angular 1.2.x does not support the Promise/A+ syntax for $q
.
Can you check with this manifest: http://data.madebymark.nl/cordova-app-loader/issues/angular-q/manifest.json
. (Please use http://data.madebymark.nl/cordova-app-loader/
as your serverRoot
).
Still have the issue then?
from cordova-app-loader.
I believe I found what was wrong and it was entirely my fault. So sorry for wasted time!
from cordova-app-loader.
No problem!
from cordova-app-loader.
Hi Mark, I found an error in your example code in the Readme.md, that had me stuck when trying to include. You write
var fs = CordovaPromiseFS({
persistent: true, // or false
storageSize: 20_1024_1024, // storage size in bytes, default 20MB
concurrency: 3 // how many concurrent uploads/downloads?
Promise: require('promiscuous') // Your favorite Promise/A+ library!
});
And I just c&p'd the code and was wondering why replacing require('promiscuous')
with $q
resulted in an error. Turns out, there is a comma missing after concurrency: 3
and Chrome's feedback led me a bit astray before finding that. You might want to correct that;-) Apart from that: congrats and thanks for the library!
from cordova-app-loader.
Related Issues (20)
- Auto-reset when updating apk HOT 2
- Is it possible to custom remote file url
- problem and suggest HOT 1
- How to deal with fonts
- Calling download() never finishes. HOT 3
- onSingleDownloadProgress is not a function HOT 3
- Error: Not allowed to load local resource
- Remote Updating HTML files? HOT 2
- file is long time cached by server,the file do not affected!
- Getting FileError
- stuck when starting the app
- Multiple servers: one server per each AppStore app version
- Updates not working in combination with cordova-plugin-crypt-file HOT 1
- Still having issues with Phonegap Developer app
- Question: Does this way of auto-updating go against the guidelines of Apple? HOT 3
- Error code 1 when cloning demo - no exception message
- Cordova plugin HOT 1
- download promise is neither getting resolved nor rejected HOT 1
- app.js file inside www is not updated with latest code HOT 4
- This plugin not working in android
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-app-loader.