paldepind / flyd

The minimalistic but powerful, modular, functional reactive programming library in JavaScript.
MIT License
1.56k stars 85 forks source link

flyd-concat #99

Closed StreetStrider closed 8 years ago

StreetStrider commented 8 years ago

Hello. I think the core missing concat which will join streams sequentially, as an opposite to merge which is doing this in parralel. I believe such task can be solved via some combination of already existent utilities, but I think this is very-very fundamental thing, so it deserves to be done in core. What do you think on this? Can we work on it?

c-dante commented 8 years ago

That would be a separate module and not in core (merge could be argued as flyd.module as well -- I think it's in core for convenience)

I'm also curious what a use case for that would be.

StreetStrider commented 8 years ago

@c-dante,

separate module and not in core

sorry, this was confusing; by «core» I mean put it to modules along with merge. I was thinking about use-case for streams like gulp vinyl streams. Looks like merge can be used for this, since we do not care about order of vfs objects in vinyl stream. concat might be applicable where we need to join streams and preserve order of events.

c-dante commented 8 years ago

Should be super easy -- you can go ahead and make it + PR to modules, I'm sure it'll get pulled in.

StreetStrider commented 8 years ago

@c-dante, I was thinking about this and seemes like you're right — there's no need to concat, since we have merge. The fact is that Flyd is super-reactive and stores/caches nothing (unlike some other streaming systems which have caching and backpressure). So when you need concat you really have to use merge instead or you will definitely lose some events.

My intention is to build something like gulp-over-flyd. I've already implemented flyd-glob. So I want to have an ability to join some file-streams. I think merge is OK for this kind of task.

On the other hand I'm open to implementing it and PR if any demand occur.