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

removeEventListener result #63

Open
sinyakin opened this issue Feb 5, 2020 · 1 comment
Open

removeEventListener result #63

sinyakin opened this issue Feb 5, 2020 · 1 comment

Comments

@sinyakin
Copy link

sinyakin commented Feb 5, 2020

  1. removeEventListener method has comment "If the operation is successfully completed, the method returns true, otherwise false"
    But this method never return false, only true or exception.

  2. Sometimes I get "Event listener already added" error, but I don't know why.
    every time after working with port I perform removeEventListener. Can you help me?

@tresf
Copy link

tresf commented Feb 5, 2020

the method returns true, otherwise false

Agreed that appears to be incorrect. Instead it either removes the listener or throws an exception. The documentation is incorrect.

Sometimes I get "Event listener already added" error, but I don't know why.
every time after working with port I perform removeEventListener. Can you help me?

A unit test is required to know for sure, so you should provide a small code snippet which reproduces this. Worth noting, closing the port implicitly removes the listener, so you should not attempt to remove a listener after closure. The exception thrown in this scenario isn't the same as you're mentioning, so the best way to reproduce the issue is to know how to reproduce it.

public boolean closePort() throws SerialPortException {
checkPortOpened("closePort()");
if(eventListenerAdded){
removeEventListener();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants