You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The goal is to test the contents of a channel, and only move on if the test succeeds.
In the current implementation, this is how I achieve it:
Gather the channel items into a list with collect
Run some tests while mapping the channel to itself with map
Undo gathering of channel items by spreading them with flatten
ch =Channel.of(1, 2, 3)
ch = ch.collect().map({ list->// Run a test that failsif (list.sum() >5) exit(1, 'ABORT')
// Return if test succeedsreturn list
}).flatten()
// This is printed only if test succeeds
ch.view()
The issue is that I have to transform the channel and then un-transform it just for a test, and the test can't be run on the channel itself, just a list representation of that channel.
Suggested implementation
Ideally a way to formally interrupt a pipeline at a given point:
ch =Channel.of(1, 2, 3)
ch = ch.try({ it->
it.sum().subscribe({ sum->// Run a test that failsif (sum >5) thrownewException('ABORT')
})
}).catch({ error->
exit(1, error)
})
// Error was raised so nothing afterwards gets executed
ch.view()
This discussion was converted from issue #2548 on February 09, 2022 21:14.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
The goal is to test the contents of a channel, and only move on if the test succeeds.
In the current implementation, this is how I achieve it:
collect
map
flatten
The issue is that I have to transform the channel and then un-transform it just for a test, and the test can't be run on the channel itself, just a list representation of that channel.
Suggested implementation
Ideally a way to formally interrupt a pipeline at a given point:
Beta Was this translation helpful? Give feedback.
All reactions