-
Couldn't load subscription status.
- Fork 1.4k
Closed
Description
I have the use case where I want to take a decision based on an effect.
For ex: I want to walk a directory tree structure, and do things based on file existence.
I find a way to do it like that:
ZStream.fromEffect(
Task.effect(file.exists).catchAll(ex =>
logger.error(ex.message *> ZIO.succeed(false)
)
).flatMap(cond =>
if(!cond) ZStream.empty
else {
ZStream.fromIterator(Task.effect(file.children)).... etc
But it feels combersome. I would love to have a combinator looking like:
ZStream.ifFromEffect(effect (: ZIO[Any, Nothing, Boolean]))(ifTrue: ZStream)(ifFalse: ZStream)
Haypierre
Metadata
Metadata
Assignees
Labels
No labels