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 coroutines interop module #374

Merged
merged 12 commits into from
Sep 15, 2019
Merged

Conversation

ZacSweers
Copy link
Collaborator

This introduces a new interop artifact for interop between Completable/ScopeProvider and CoroutineScope. The idea is to offer this interop for general use, but also so anyone migrating from rx to coroutines (or the other way around!) can reuse existing machinery to ease migrations in the meantime.

Resolves #371

@ZacSweers ZacSweers added this to the 1.4.0 milestone Sep 12, 2019
@ZacSweers ZacSweers self-assigned this Sep 12, 2019
@ZacSweers
Copy link
Collaborator Author

Tests are coming, just sticking up for early review for the implementation. Still not 100% sure I know what I'm doing with structured concurrency so want to get more eyes on this :)

Copy link
Collaborator

@ShaishavGandhi ShaishavGandhi left a comment

Choose a reason for hiding this comment

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

LGTM from my understanding of structured concurrency which is limited. The tests will give me a lot more confidence.

@ZacSweers
Copy link
Collaborator Author

Implemented the tests in d186f8f

I'm still not totally sure about requiring a CoroutineContext, vs maybe giving it a default value of something like Job() or SupervisorJob(). Thoughts?

@ZacSweers
Copy link
Collaborator Author

Went for it after digging through some coroutines sources. I think that's the right move.

Super nice high order function with receiver API
@ZacSweers
Copy link
Collaborator Author

Wrote something really nice building on top of the building blocks here. Now you can do this:

scopeProvider.asCoroutineScope {
  someObservable.autoDispose().subscribe()
}

@ZacSweers
Copy link
Collaborator Author

Pulled out the context APIs to #375 instead

import kotlinx.coroutines.isActive
import org.junit.Test

class AutoDisposeCoroutinesInteropTest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice tests!

@ZacSweers ZacSweers merged commit cf96ca6 into master Sep 15, 2019
@ZacSweers ZacSweers deleted the z/coroutinScopeInterop branch September 15, 2019 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ScopeProvider -> CoroutineScope interop
2 participants