-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to write a transducer? #519
Comments
Hi @episage the blip protocol sounds interesting couple of questions for you to help us out. So it seems like you are trying to create a duplex like stream and not a transducer based on your above comment. Seems like a subject https://github.com/mostjs-community/subject could be more suitable. A transducer is a composable and efficient way of transforming data without an intermediate step. Where a duplex or transform stream is one that has both properties of being readable and writable which seems what you want ? Also out of personal curiosity if you got it to work with the Nodejs transform class why change it in favor most? Let me know if I’m understanding you correctly :) |
Hi @davidchase
The Blip messaging protocol is However I would also like to try
Here is an example that works in NodeJS:
I hope you get the idea. I looked at |
An even simpler approximation would be answer to question: "How to write a GZIP compressor with |
Hi @episage. It's unfortunate that the word stream is quite overloaded. If I had it to do over again, I'd not use it to describe the data structure that most provides. I'm sorry for any confusion it's caused. Most streams and node streams have different goals and intended use cases. For example, most streams are targeted primarily at discrete events (e.g. mouse clicks), and node streams are targeted primarily at chunked data. Both can be used for other purposes, of course, but you'll start feeling the tension as you get further from each's intended use case. They also have different APIs: pipe() is a node stream API, and it's not a goal of most to support it, just as until() and awaitPromises() are most APIs, and it's unlikely such things would be commonly useful for chunked data stream I'd recommend looking for a chunked data stream abstraction that fits your use case and works in browsers. Perhaps there is a polyfill or other userland implementation of the w3c streams proposal that would be helpful for your use cases. |
Um, I'm sorry to hear that :( I expected all the streams to be created equal. Also, I read a topic on GH with argument about I think maintainer should put a note on the front page. I definitely got lost in the Stream/FP/fantasy-land |
@briancavalier You mention that |
DominicTarr’s event stream is another wrapper over Nodejs streams. He has quite a few them (check out his pull-stream) as a lot of folks wanted a nicer api to deal with when using Nodejs streams. In my experience tension comes into play when use a library like most of which has no way of handling back pressure nor really should and we use in place of Nodejs streams and try to use Nodejs streams for things other than data process
Do you have a link? I’ve used Ramda with Nodejs streams and had no issues |
@episage what did you end up going with to bucket your tick data? Regarding transducers, it's nothing crazy, pretty good description and demo by Brian Lonsdorf here |
I ended up using https://www.timescale.com/ (postgresql plugin really) to bucked the tick data. Look at Thanks for the video link, I watched it |
Hi, I want to implement Blip messaging protocol (
https://github.com/couchbaselabs/BLIP-Cocoa/blob/master/Docs/BLIP%20Protocol.md
, it's like TCP over WebSockets).The data stream looks like this:
-a-b-c-d-e->
and the output are messages
-----M----->
One message consist of many data chunks.
It is specified by the protocol when the chunks are combined and outputted as a Message.
How can I implement something like this using
most
?I guess it should be a transducer.
I worked with nodejs Transform stream and it worked perfectly.
What's the eqivalent of
https://nodejs.org/api/stream.html#stream_class_stream_transform
?I had an attempt to write a transducer using the following code copied from
transducer-js
but I have no idea how to proceed further:The code basically throws an error that
xf
is not defined. It's not.I want something simple like NodeJS
.pipe
. Look:The text was updated successfully, but these errors were encountered: