Skip to content

Commit

Permalink
feat(core): add methodName to Cordova Decorator (#3558)
Browse files Browse the repository at this point in the history
closes #3557
  • Loading branch information
EinfachHans committed Nov 19, 2020
1 parent f71b65d commit 46853b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions DEVELOPER.md
Expand Up @@ -168,6 +168,7 @@ A decorator to wrap the main plugin class, and any other classes that will use `
Checks if the plugin and the method are available before executing. By default, the decorator will wrap the callbacks of the function and return a Promise. This decorator takes the following configuration options:

- **observable**: set to true to return an Observable
- **methodName**: an optional name of the cordova plugins method name (if different from wrappers method name)
- **clearFunction**: an optional name of a method to clear the observable we returned
- **clearWithArgs**: This can be used if clearFunction is set. Set this to true to call the clearFunction with the same arguments used in the initial function.
- **sync**: set to true if the method should return the value as-is without wrapping with Observable/Promise
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/transformers/methods.ts
Expand Up @@ -54,7 +54,7 @@ function getMethodBlock(method: ts.MethodDeclaration, decoratorName: string, dec
default:
return ts.createCall(ts.createIdentifier(decoratorMethod), undefined, [
ts.createThis(),
ts.createLiteral((method.name as any).text),
ts.createLiteral(decoratorArgs?.methodName || (method.name as any).text),
convertValueToLiteral(decoratorArgs),
ts.createIdentifier('arguments'),
]);
Expand Down
5 changes: 5 additions & 0 deletions src/@ionic-native/core/decorators/interfaces.ts
Expand Up @@ -33,6 +33,11 @@ export interface PluginConfig {

export interface CordovaOptions {
destruct?: boolean;
/**
* If the method-name of the cordova plugin is different from the wrappers one, it can be defined here
*/
methodName?: string;

/**
* Set to true if the wrapped method is a sync function
*/
Expand Down

0 comments on commit 46853b4

Please sign in to comment.