Here’s one way to solve the problem of if one channel is empty, use another one.
params.fill = false
workflow {
ch_something = params.fill ? Channel.of(1..3) : Channel.empty()
ch_backfill = Channel.of(4..6).toList()
ch_something.collect().concat(ch_backfill).first().flatMap().view()
}
This uses the property that collect only emits a list if there’s something in the channel. Use concat to make sure the channel contents stay in order. and then use first() to take the first list from the concatenated channels. If ch_something is empty, there will be nothing, and the list from ch_backfill is taken.