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

withViewLifecycleScope does not continue collection after the first view LifecycleScopeOwner is destroyed #236

Closed
RBusarow opened this issue Jun 4, 2021 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@RBusarow
Copy link
Owner

RBusarow commented Jun 4, 2021

Given this code:

class MyFragment: Fragment() {

  val myViewModel = ...

  init {
    receiverScope.withViewLifecycle(this) {
      myViewModel.myFlow
        .onEach { ... }
        .launchOnStart()
    }
  }
}

Collection will happen after the fragment is initially started. If the fragment is pushed to the backstack and the View is destroyed, then the coroutine which observes the lifecycle is cancelled and not restarted. If the fragment is brought back into view and a new viewLifecycleOwner is created, it will not re-start collection.

@RBusarow RBusarow added the bug Something isn't working label Jun 4, 2021
@RBusarow RBusarow added this to the 1.0.0-beta10 milestone Jun 4, 2021
@RBusarow RBusarow closed this as completed Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant