Remove all listeners for a plugin#185
Remove all listeners for a plugin#185hampoelz wants to merge 1 commit intocapacitor-community:mainfrom
Conversation
|
Is there any documentation on how to use events on a Capacitor Electron plugin? |
|
@matallui You can find a small example in the |
|
@hampoelz thanks! I have something similar but it's not working.
It sounds like the above example would let you do something like this, from the client code: But the last two lines won't work because those methods are not implemented on the plugin. I also don't understand what this means from the example: Where do I access Any help is much appreciated! |
|
@matallui your code looks good to me. If you're using Capacitor with the bundled Capacitor-Core you can access your plugin with (I'm using |
|
@hampoelz thanks! I actually got it working by simply type casting the plugin to This is what is working for me right now. I guess those methods are added at runtime, so Typescript was not letting me access methods that were not defined by the plugin. At least that's my take on this. |
|
@matallui may I ask what are the contents of "SomePlugin" in your case when you got the addListener to work? while I am a bit unfamiliar with typescript, my interface has this method: and my class is written similarly as yours where it "extends EventEmitter and Implements SamplePlugin" but I don't call addListener and it returns an error: I have gotten my other functions to work when it doesn't involve addling listeners so I'm hoping someone could help me out with this one. |
|
@Gangceen I used Capacitor once about 2 years ago, at a previous job. I can't remember exactly what I did back then, and I don't have access to that code to share, unfortunately. If the info here is not enough, not sure I can really be of much help. |
Match
removeAllListeners()function with Capacitor API to remove all listeners of a plugin.Refs #137