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

fix EventuallyPredicate, add a producerless version, and inform user … #2046

Merged
merged 3 commits into from Feb 9, 2021

Conversation

jschneidereit
Copy link
Member

…about predicate failures for #2044

@xeruf
Copy link
Contributor

xeruf commented Feb 5, 2021

yeah, might as well call it until again ^^

Either way, you need to rework or remove this, as it is incorrect:

suspend fun until(duration: Duration, interval: Interval = 1.seconds.fixed(), f: suspend () -> Boolean) =
   eventually(duration, interval, f = f)

It will return immediately after the first try if that doesn't throw an exception (which until lambdas are not supposed to do) regardless of the returned boolean value.

@sksamuel
Copy link
Member

sksamuel commented Feb 6, 2021

It will return immediately after the first try if that doesn't throw an exception (which until lambdas are not supposed to do) regardless of the returned boolean value.

That's how eventually has always worked - it looked for exceptions.

Now you can additionally evaluate the predicate, combining the power of both eventually and until.

/**
* Runs a predicate until the predicate returns true as long as the specified duration hasn't passed
*/
suspend fun eventuallyPredicate(
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this work without requiring the name overload ?

@sksamuel sksamuel merged commit 3d5a15a into master Feb 9, 2021
@sksamuel sksamuel deleted the jschneidereit/feature/2044 branch February 9, 2021 01:06
@xeruf
Copy link
Contributor

xeruf commented Feb 9, 2021

That's how eventually has always worked - it looked for exceptions.

Yes, but until never worked like that, so this alias was bogus.

@sksamuel
Copy link
Member

sksamuel commented Feb 9, 2021 via email

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.

None yet

3 participants