Skip to content
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

Is it possible to join outputs #177

Closed
sray opened this issue Jan 21, 2014 · 15 comments
Closed

Is it possible to join outputs #177

sray opened this issue Jan 21, 2014 · 15 comments

Comments

@sray
Copy link

sray commented Jan 21, 2014

Is it possible to combine the input of two steps for the next step like this:
inputA --> taskA __
..................................
.................................... --- taskF --> output
inputB --> taskB __/

If so, how? If not, are there any ideas how to get that kind of pipeline flexibility?

@dashed
Copy link
Contributor

dashed commented Jan 21, 2014

Yes it's possible -- I'm unsure if any gulp plugin exists (most likely).

All you need to do is pipe multiple streams to a single stream, and then send end event once the last stream is finished.

@stryju
Copy link
Contributor

stryju commented Jan 21, 2014

not sure that a return value of a task should be the stream...

seems more like a task for an internal function and event-stream merge

function getStream1() {
  return gulp.src( ... )
    pipe( ... );
}

function getStream2() {
  return gulp.src( ... )
    pipe( ... );
}

require('event-stream')
  .merge( getStream1(), getStream2() /*, ... */ )
    .pipe( gulp.dest( ... ) );

@dashed
Copy link
Contributor

dashed commented Jan 21, 2014

@stryju That's the idea I was considering.

If OP wants streams piped syncrhonously (order), then that's an entirely different story.

@dashed
Copy link
Contributor

dashed commented Jan 21, 2014

@stryju @Saheba

es.merge doesn't have to be 'readable-only'.

The following works as well:

gulp.src(...)
    .pipe(es.merge( getStream1(), getStream2() /*, ... */ ))
    .pipe(...)

es.merge will act like a passthrough stream for any stream it has been piped onto.

@stryju
Copy link
Contributor

stryju commented Jan 21, 2014

@dashed i didn't say that es.merge has to be read-only - what i meant was that the task should be an entity, not a "getter" :-)

@robrich
Copy link
Contributor

robrich commented Jan 21, 2014

As a point of clarification, you can combine streams this way. Tasks don't pipe results into other tasks. You're on the right track thinking about this with piping plugins and functions together. Well done.

@stryju
Copy link
Contributor

stryju commented Jan 21, 2014

👍 @robrich

@dashed
Copy link
Contributor

dashed commented Jan 21, 2014

@stryju I see. I had meant that your example implied as such.

@yocontra
Copy link
Member

The lazypipe module might help here

@yocontra
Copy link
Member

Anyways to sum up the answers: event-stream's .merge, gulp-util's .combine, normal stream pipes, lazypipe, etc.

@sray
Copy link
Author

sray commented Jan 23, 2014

thanks a lot for all your answers :)

@clkao
Copy link

clkao commented Feb 21, 2014

Hi @dashed you mentioned about merging streams with order, what are the best options for that?

@darsain
Copy link
Contributor

darsain commented Feb 21, 2014

@clkao using multiple streams in one task (the second example).

@clkao
Copy link

clkao commented Feb 21, 2014

@darsain thanks streamqueue works great!

@max-ch9i
Copy link

streamqueue really worked great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants