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

await not available in Cordova #5

Open
JohnMcLear opened this issue Aug 5, 2019 · 3 comments
Open

await not available in Cordova #5

JohnMcLear opened this issue Aug 5, 2019 · 3 comments

Comments

@JohnMcLear
Copy link
Contributor

JohnMcLear commented Aug 5, 2019

Cordova example currently expects async/await to be available and that is not the case.


        gpcard.connect().then(() => {
            console.log("connected")    
        }).catch(error => {
            console.error(error)
        })

should work

@benbenbenbenbenben
Copy link
Member

The Cordova example at https://github.com/dcdc-io/node-gp-phonegap/blob/master/www/js/index.js works using async/await on the devices I've tested.

Stock LG G4 Android 6.0

Stock Sony Xperia XZ Premium Andoird 9.0

I've not delved into the Chrome/webview details but if there is a problem I suspect it's there?

As a workaround I would recommend against using the promise then/catch API and instead transpiling down for older APIs

@JohnMcLear
Copy link
Contributor Author

JohnMcLear commented Aug 5, 2019 via email

@benbenbenbenbenben
Copy link
Member

Also, async/await don't work a the top of the file's scope - i.e.

// foobar.js
async function foo() {
    return 1;
}
// won't work - SyntaxError: await is only valid in async function
await foo();

async function bar() {
    // will work
    await foo();
}
bar();

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