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

Use rememberCoroutineScope in AsyncImagePainter. #2220

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

colinrtwhite
Copy link
Member

Fixes #2181.

// Create a new scope to observe state and execute requests while we're remembered.
val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
rememberScope = scope
if (rememberJob != null) return
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be safer to use if(rememberJob?.isActive == true) return ?
Maybe the coroutine won't ever be cancelled without calling clear() though?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yep that's probably better 👍. Theoretically Compose could cancel the parent scope at any time.

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.

AsyncImagePainter should use rememberCoroutineScope
2 participants