MCPcopy Index your code
hub / github.com/ionic-team/capacitor / createPluginMethod

Function createPluginMethod

core/src/runtime.ts:78–98  ·  view source on GitHub ↗
(impl: any, prop: PropertyKey)

Source from the content-addressed store, hash-verified

76 };
77
78 const createPluginMethod = (impl: any, prop: PropertyKey): ((...args: any[]) => any) => {
79 if (pluginHeader) {
80 const methodHeader = pluginHeader?.methods.find((m) => prop === m.name);
81 if (methodHeader) {
82 if (methodHeader.rtype === 'promise') {
83 return (options: any) => cap.nativePromise(pluginName, prop.toString(), options);
84 } else {
85 return (options: any, callback: any) => cap.nativeCallback(pluginName, prop.toString(), options, callback);
86 }
87 } else if (impl) {
88 return impl[prop]?.bind(impl);
89 }
90 } else if (impl) {
91 return impl[prop]?.bind(impl);
92 } else {
93 throw new CapacitorException(
94 `"${pluginName}" plugin is not implemented on ${platform}`,
95 ExceptionCode.Unimplemented,
96 );
97 }
98 };
99
100 const createPluginMethodWrapper = (prop: PropertyKey) => {
101 let remove: (() => void) | undefined;

Callers 1

wrapperFunction · 0.85

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected