DEV Community

Discussion on: Simple pub/sub pattern (OOP) using pure Ruby

Collapse
 
mxldevs profile image
MxL Devs

Is there a way to avoid holding a reference to the printer? For example say I wanted an unknown number of printers to receive the broadcast and independently perform a print task.

Would this new change still be considered publish-subscribe pattern?

Collapse
 
pashagray profile image
Pavel Tkachenko • Edited

Yes! You may need to introduce Event Bus. It's like a huge highway, where publishers post events. Subscribers listen to that Event Bus, rather than Publishers.

EventBus