Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ZIO#whenRef and ZIO#whenFiberRef #7615

Merged
merged 1 commit into from
Dec 8, 2022
Merged

Implement ZIO#whenRef and ZIO#whenFiberRef #7615

merged 1 commit into from
Dec 8, 2022

Conversation

adamgfraser
Copy link
Contributor

Resolves #7611.

@adamgfraser adamgfraser merged commit afbfa6a into zio:series/2.x Dec 8, 2022
@adamgfraser adamgfraser deleted the 7611 branch December 8, 2022 20:22
@jdegoes
Copy link
Member

jdegoes commented Dec 8, 2022

🙏

* Executes this workflow when value of the specified `FiberRef` satisfies the
* predicate.
*/
final def whenFiberRef[S](ref: => FiberRef[S])(f: S => Boolean)(implicit trace: Trace): ZIO[R, E, Option[A]] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly this should be Option[S], or maybe Option[(A, S)] if we really want to hold onto the A.

The reason is that the S will change, so the user won't ever have access to the S that produced the decision to execute the effect, unless we provide it to them in the return value.

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.

Add ZIO#when methods for running effects conditionally based on state
3 participants