A publish/subscribe helper class that uses micro-tasks to relay messages to many subscribers.
Note that the callbacks don't run immediately. They are scheduled to a micro-task to be called later on.
new Speaker(...initial) : Speaker
listen
before the first time speak
is called.
Speaker.listen(callback : (...args) => undefined) : [...args]
Speaker.speak(...args)
speak
is called again.
Speaker.forget(callback)
Speaker.silence()
Additionally, the module exposts the ImmediateSpeaker
class,
which does the exact same as a normal speaker,
but executes its callbacks immediately instead of scheduling a micro-task.
The API is the exact same as a normal Speaker
.