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

feat(core): add methodName to Cordova Decorator #3558

Merged
merged 1 commit into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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