-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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(printer): add printer plugin #225
Conversation
@@ -122,6 +124,7 @@ export { | |||
Insomnia, | |||
Keyboard, | |||
Network, | |||
Printer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line as it's not needed. export *
takes care of this
In summary, both functions should just contain |
TL;DR: No extra parameters are needed, just replace the inner functionality with Explaination: So for example, let's assume we have a plugin that has the following method: plugins.myPlugin.myMethod = function(optionA, optionB, successCallback, errorCallback) {
// do stuff here
try {
successCallback('return useful info');
} catch (e) {
errorCallback('return error');
}
}; To wrap this up with @Plugin({
plugin: 'cordova-my-plugin',
pluginRef: 'plugins.myPlugin',
repo: 'https://my.github/myuser/myrepo'
})
export class MyPlugin {
/**
* Some useful docs here!
*/
@Cordova()
static myMethod(nameForOptionA: string, nameForOptionB: boolean): Promise<any> {return; }
} Now if we call that method from our app. It will do the following:
You can configure the decorator to behave differently in case the original plugin is written in a different format. So basically, when writing a wrapper, you don't need to add any functionality. That is because the decorators we use overwrites your method functionality. There are special cases, like defining a wrapper for a property, or defining an instance based plugin. Thank you for contributing 😁 |
Great explanation! Thank you for all of that info, it is really appreciated. I'll push a new commit in a couple of minutes |
There we go. Please let me know if I still missed something |
Looks good now. Thanks @zakton5 ! |
Added wrapper for the cordova-plugin-printer.
Here is the git repo: https://github.com/katzer/cordova-plugin-printer.git