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

fix(core): Call native implementation before web implementation #4493

Merged
merged 7 commits into from
Apr 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions core/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,8 @@ export const createCapacitor = (win: WindowCapacitor): CapacitorInstance => {
impl: any,
prop: PropertyKey,
): ((...args: any[]) => any) => {
if (impl) {
return impl[prop]?.bind(impl);
} else if (pluginHeader) {
const methodHeader = pluginHeader.methods.find(m => prop === m.name);

if (pluginHeader) {
const methodHeader = pluginHeader?.methods.find(m => prop === m.name);
if (methodHeader) {
if (methodHeader.rtype === 'promise') {
return (options: any) =>
Expand All @@ -134,7 +131,11 @@ export const createCapacitor = (win: WindowCapacitor): CapacitorInstance => {
callback,
);
}
} else if (impl) {
return impl[prop]?.bind(impl);
}
} else if (impl) {
return impl[prop]?.bind(impl);
} else {
throw new CapacitorException(
`"${pluginName}" plugin is not implemented on ${platform}`,
Expand Down