Skip to content

removeEventListener result #63

Open

Description

@sinyakin
  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?

Activity

  1. tresf commented on Feb 5, 2020

    @tresf

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions