Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@blast-hardcheese
Copy link
Contributor

Useful in the case where you have a Ref[Boolean] and need to perform some effects, for example

ZIO.condM(isEnabled)(consumeNext, log.info("Disabled").as(StopProcessing))

@adamgfraser
Copy link
Contributor

@blast-hardcheese This seems pretty similar to ZIO.ifM. Would that work for your use case?

@blast-hardcheese
Copy link
Contributor Author

@adamgfraser Hmm, it does indeed, and the implementation is identical. Let me update this PR in order to point users of cond over to ifM, since there's no natural symmetry there.

@blast-hardcheese
Copy link
Contributor Author

as for my initial example,

ZIO.ifM(isEnabled)(consumeNext, log.info("Disabled").as(StopProcessing).flip)

would do what I want quite nicely.

@blast-hardcheese
Copy link
Contributor Author

Done, thank you!

@blast-hardcheese blast-hardcheese changed the title Add ZIO.condM Add note for ifM to ZIO.cond Dec 5, 2020
@adamgfraser adamgfraser merged commit b543a65 into zio:master Dec 5, 2020
@blast-hardcheese blast-hardcheese deleted the condM branch December 6, 2020 17:36
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

Successfully merging this pull request may close these issues.

2 participants