If you're putting data into a channel, why not just add the transducer to the 
channel creation so it is applied as you pull values off the channel?

Sean

On Sep 21, 2014, at 3:01 PM, Wilker <wilkerlu...@gmail.com> wrote:

> Hi guys,
> 
> I'm playing with transducers here, and trying out stuff just for fun, there 
> is something that I'm kind stuck on how to approach. I understand the great 
> abstraction that transducers provide over don't carrying about the input 
> source type, but I'm struggling to deal with async operations into my 
> pipeline.
> 
> For example, I'm working with Node.JS async API's for file system operations, 
> I want to stick with the async versions since I don't wanna block the event 
> loop of Node.
> 
> So, let's say I have a source with ["dir", "other"] and I wanna create an 
> operation that will simple filter which paths exists, are directories, and 
> then list the `ls` of each remaining entry.
> 
> So, I first created "channel returning" functions for the Node operations, 
> I'll not put the code here because I don't think it's really relevant here, 
> just consider that I have them.
> 
> So, my pipeline would start looking something like this:
> 
> (comp (filter exists?)
>       (filter is-dir?)
>       (mapcat readdir))
> 
> Of course, this doesn't works... Because `exists?`, `is-dir?` and `readdir`, 
> all of them return channels, so the filter would always pass since a channel 
> is always a valid value... The same applies to mapcat, it would try to concat 
> into a channel...
> 
> This is making me notice some barrier to be able to compose async operations 
> with regular operations.
> 
> Maybe would be possible to "sign" somehow operations to make then run async?
> 
> The only viable option that I've found is with pipeline-async, which accepts 
> an async function, but that doesn't composes with the other operations (map, 
> filter, drop-while...)
> 
> Is there already a solution to that? Or maybe I'm just doing it wrong and 
> there is a better way to handle those cases?
> 
> I would love to know how you guys are handling those kind of situations.
> 
> Thanks.


Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to