substream
substream copied to clipboard
Add ability to emit client <-> server events
This adds the primus-emit
functionality to the SubStream
instance.
I don't like the fact that it uses a trigger
method instead of the usual emit
, but I tried to override the emit
method and it broke the tests.
cc: @3rd-Eden @siddo420
The trigger
name though.. yuk. It triggers my OCD hard especially because we already have primus-emit
that just uses emit
for the event emitting. So this introduces a different API for emitting and when you pair substream with primus-emit you end up with really odd code.
I totally agree :/
Maybe we can remove the trigger method and document that if you want to trigger an even on the substream you can use something like this:
substream._write({ emit: [ eventName, arg ] });
but I don't know if it is any better, it's cumbersome and uses the private _write
method.