Skip to content
Discussion options

You must be logged in to vote

You could use count and subscribe to check whether the incoming channel is empty before you call collect / collectFile. Here's an example:

// items to collect
ch_samples = Channel.empty()

ch_samples
  | count
  | subscribe { n ->
    if ( n == 0 ) error "There are no items to collect"
  }

ch_samples
  | collect

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by bentsherman
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #3730 on March 08, 2023 17:18.