zeusdeux / preach

A lightweight pubsub utility for node and the browser.

Home Page:npmjs.org/package/preach

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why all the throws?

dalgard opened this issue · comments

I like the API, however, I don't quite understand the use of channels? Why would the library throw and exception just because no listeners have been set up for a certain event?

The point of using a mediator/pub-sub pattern is having loose coupling, but from the documentation, it looks as though I am forced to register at least one subscriber before publishing some event. It doesn't make sense to me.

@dalgard Valid point.

I had it initially throw for all those cases as I needed a programmatic way of knowing when something "not right" had occured. That's all. It was very specific to the codebase that preach was used with.

But yes, pub-sub usually does have loose coupling/no delivery guarantees etc. Fixed. Cheers!

Thanks! 👍