Skip to content

EventListener::new footgun #89

@zeenix

Description

@zeenix

Copy&pasting from the matrix channel to avoid repeating:

zeenix: this method takes an Event ref but doesn't actually setup the listener to listen to this event. This seems like a pretty big footgun
Saltbag: The only other option is to have it insert itself into the list on await, which has its own footguns. It can’t be set up in new since it needs to be pinned.
zeenix: it's just a very strange and unintuitive api now. I see multiple issues here:

  • EventListener existing w/o listening is just strange. The name implies something that's listening.
  • new takes a Event ref but doesn't listen to the given event.
  • The footgun of awaiting a listener w/o calling listen on it. That state should not be allowed to ever exist.

If listening require pinning, that should always be implied then. That's the whole point of EventListener type. At the very least, new and EventListener docs should document all these caveats well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions