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

refactor(diagnostic plugin) #1458

Merged
merged 4 commits into from
May 9, 2017
Merged

refactor(diagnostic plugin) #1458

merged 4 commits into from
May 9, 2017

Conversation

dpa99c
Copy link
Contributor

@dpa99c dpa99c commented May 3, 2017

update camera API function signatures to support cordova.plugins.diagnostic@3.6.0. See dpa99c/cordova-diagnostic-plugin@515317e

@ihadeed
Copy link
Collaborator

ihadeed commented May 3, 2017

@dpa99c

Thanks for the PR!

TLDR: It just needs one quick change, we need to specify successIndex and errorIndex in the @Cordova() decorator as follows:

@Cordova({
  successIndex: 1,
  errorIndex: 2
})

Detailed explanation:

When there is an optional parameter, we need to add successIndex and errorIndex properties to the @Cordova() decorator. The decorator can't tell what the signature of the method is, it just takes the arguments passed to the function and passes them to the original method.

For example:

// if we call isCameraAvailable without explicitly providing value for externalStorage
this.diagnostics.isCameraAvailable();

// it will result in the original method being invoked like this
cordova.plugins.diagnostic.isCameraAvailable(onSuccess, onError);

So we need to specify our success and error index in the decorator as follows to fix this issue:

@Cordova({
  successIndex: 1,
  errorIndex: 0
})

Now the original method will be invoked with the following arguments if we use the same example above:

cordova.plugins.diagnostic.isCameraAvailable(undefined, onSuccess, onError);

@ihadeed ihadeed merged commit a4151ab into danielsogl:master May 9, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants