Skip to content

$pub should not throw an exception if no events are registered #3

@dustincleveland

Description

@dustincleveland

In most pub/sub implementations I've seen, publishing an event when there are no subscribers fails silently. In the current implementation, I would have to wrap try/catch logic around all of my calls to $pub. I propose that $pub simply returns without an exception when there are no registered events. I believe this has two benefits:

  1. It simplifies the code that consumers have to write; no need for try/catch logic
  2. It promotes loose coupling; consumers don't have to worry about the state of the rest of the application.

I wanted to see if this idea has support before I create a pull request?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions