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 #938 — fixes resource handling in Iterant.repeat, adds Iterant.retryIfEmpty #965

Merged
merged 4 commits into from Jul 31, 2019

Conversation

@alexandru
Copy link
Member

commented Jul 28, 2019

See #938 for the bug description.

This PR fixes iterant.repeat to handle resources (Scope) correctly.

Because repeat returns empty on empty streams, this PR also adds a new retryIfEmpty operator:

import scala.util.Random

val stream = Iterant[Coeval].suspend(Coeval {
  val nr = Random.nextInt()
  if (nr % 10 != 0)
    Iterant[Coeval].empty[Int]
  else
    Iterant[Coeval].of(1, 2, 3)
})

stream.retryIfEmpty(None).repeat
alexandru added 4 commits Jul 28, 2019
@oleg-py
Copy link
Collaborator

left a comment

I'm not sure that we want to special-case empty streams in this fashion (e.g. fs2 doesn't do that), but resources not staying open is the most important thing here, so we probably should go ahead.

@Avasil
Avasil approved these changes Jul 30, 2019

@alexandru alexandru merged commit f2e53ca into monix:master Jul 31, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.