substream icon indicating copy to clipboard operation
substream copied to clipboard

Add ability to emit client <-> server events

Open lpinca opened this issue 9 years ago • 3 comments

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

lpinca avatar Dec 15 '15 16:12 lpinca

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.

3rd-Eden avatar Dec 17 '15 15:12 3rd-Eden

I totally agree :/

lpinca avatar Dec 17 '15 15:12 lpinca

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.

lpinca avatar Dec 17 '15 15:12 lpinca