Closed nikrowell closed 4 years ago
All good points, though I'd probably lean towards keeping things simple / passing a single object whether that's state or data. I suppose this could instead be done through multiple instances via create(initial = {}, merge = true)
, but that complicates my original motivation for having pubsub in picoapp. That said, we could drop this PR - nothing stopping me from using a separate event emitter for my picoapp use case. Preference?
Decided to give this a try and see what we think! Updated per your suggestion above, ~but my latest commit to emit-without-merge
isn't showing up here. Strange...~
pushed an update to README which trigged an update to the PR
Yo! Sorry for the delay, lost the notification and forgot to come back lol.
Yeah I think I def prefer the emit('pubsub', null, {})
as you've implemented here. It might also be nice in the future to be able to access transient data and state from the same handler.
You cool with that? The code looks great.
No worries, and thanks! I'm cool with how this works.
It might also be nice in the future to be able to access transient data and state from the same handler.
That's made possible with the second argument passed to on
, or am I missing something?
on('event', (state, data) => console.log(data))
Yep! Just saying it's another reason I like it like that. I'll pull this down and cut a new release later today!
Hey Eric - can you do a minor version bump here and update / publish picoapp's evx dependency whenever you get a chance? Please and thank you!
I published evx
the other day, but didn't think about picoapp! I'll try to do that tomorrow, thanks for the heads up. Feel free to do a PR too.
Hey @estrattonbailey ... in picoapp #19 we talked about a possible third param to
emit
that doesn't merge state and acts as a simple event emitter / pubsub interface. I realize this was mostly around my use case with picoapp, so no problem if you'd prefer not to merge this in. Cheers!