Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cordova supported platforms lack suport for ES6 Promise #5

Closed
hsmith825 opened this issue May 30, 2016 · 3 comments
Closed

Cordova supported platforms lack suport for ES6 Promise #5

hsmith825 opened this issue May 30, 2016 · 3 comments

Comments

@hsmith825
Copy link

I have not used promises before. I am getting snytactic errors in my cordova app. Research indicates that Cordova supported platforms lack suport for ES6 Promise. There is a plugin, PromisesPlugin, that says they rectifies this problem. Do you recommend this plugin for Cordova apps are should I do something else??

The particular syntax problem is of the form .then((message) => { . Your example will not build.

Thanks!
Howard

@hsmith825
Copy link
Author

The es6-promise-plugin is installed. For others that run into this problem, I get it to work with statements of the form:
ApplePay.canMakePayments()
.then(function(message) {
// Apple Pay is enabled and a supported card is setup. Expect:
// 'This device can make payments and has a supported card'
console.log(message);
})
.catch(function(message) {
// There is an issue, examine the message to see the details, will be:
// 'This device cannot make payments.''
// 'This device can make payments but has no supported cards'
console.log("message);
});

@samkelleher
Copy link
Owner

Hi Howard,

Yes you're quite right. It's not the Promise in the older webviews that might be the problem, but it is the arrow functions that is shown in my examples.

The two snippets below are functionally identical.

Works in modern devices, or JavaScript projects using a transpiler:

.then((payment) => { });

Used in older devices, or non-transpiled projects:

.then(function(payment) { });

@hsmith825
Copy link
Author

Thanks!

From: Sam Kelleher [mailto:notifications@github.com]
Sent: Monday, May 30, 2016 10:41 AM
To: samkelleher/cordova-plugin-applepay cordova-plugin-applepay@noreply.github.com
Cc: hsmith825 howard@flickitt.com; State change state_change@noreply.github.com
Subject: Re: [samkelleher/cordova-plugin-applepay] Cordova supported platforms lack suport for ES6 Promise (#5)

Hi Howard,

Yes you're quite right. It's not the Promise in the older webviews that might be the problem, but it is the arrow functions https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions that is shown in my examples.

The two snippets below are functionally identical.

Works in modern devices, or JavaScript projects using a transpiler:

.then((payment) => { });

Used in older devices, or non-transpiled projects:

.then(function(payment) { });


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub #5 (comment) , or mute the thread https://github.com/notifications/unsubscribe/ABVFjE0117JDBeJeDxW-PqNvVSDY8Ty3ks5qGyEegaJpZM4Ip0a5 . https://github.com/notifications/beacon/ABVFjDzY-cOOzF_DA5OPU1WCvpQGJ2HHks5qGyEegaJpZM4Ip0a5.gif

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

No branches or pull requests

2 participants