To "streamify" a map of callbacks
See original GitHub issueHi guys,
I was doing a facade on a legacy API where a map of callback is passed in as an arg like:
const myStupidListeners = {
aHappened: e => {},
bHappened: e => {},
cHappened: e => {}
}
invokeLegacyAPI("start", myStupidListeners)
I was trying to wrap this API to multiple event streams using bacon, so for each xHappened callback, an event stream shall be created.
But however I just can’t spin my head around how to “streamify” those callbacks using factory functions provided by Bacon, at best I’m thinking of kicking start a Bus for each callbacks and pushing events to that bus in those callbacks.
Am I missing somehing form the doc and is there a better way to do this?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Streaming Callback Function | LumenVox Knowledgebase
The callback function is called by the speech port each time there is a change in the stream status. Primarily this is used...
Read more >Add callback function to Java stream - Stack Overflow
Let's say I want to perform the following operations: List the files in a given directory (as a stream); Map each file (Path)...
Read more >Stream | Node.js v19.3.0 Documentation
The stream/promises API provides an alternative set of asynchronous utility functions for streams that return Promise objects rather than using callbacks. The ...
Read more >Callbacks, Part 3: Promise, Event, and Stream (Functional ...
Event is a truly great alternative when you realize the problem of using the standard tools, but not yet willing to use Streams...
Read more >Async mapping with promises · Issue #517 · caolan/highland
getUserFromId returns a promise _([1,2,3,4]).map(id... ... the promise handler streamifyAsync and the callback handler streamify though.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Probably a Bus is the easiest solution. There are other options but since you have three callbacks you want to pass simultaneously it’s a bit trickier.
Optionally you can
This ways you’ll get all events into one stream. Then you need to split it into three by applying different filters. Note that you could also can tag your data like
So that you
allEventsstream will output stuff likeThe Bus approach seems more approachable to me.