https://kotlinlang.org logo
#coroutines
Title
# coroutines
g

gsala

07/20/2020, 2:05 PM
In this post https://medium.com/@elizarov/structured-concurrency-anniversary-f2cc748b2401 by Elizarov, Roman mentions a use case which is very similar to a problem I have.
In fact, there are valid use-cases where you have an entity with its own life-time, like a HTTP connection, and a client code in another module of your application making a request in its own scope. You should be able to easily combine them so that request is restricted to both life-times. Currently, this is cumbersome to implement.
What's the right approach to combine two different scopes/lifecycles when launching a coroutine? In my case I have a BLE connection which creates a scope bound to the lifecycle of the connection, and I'd like a client to be able to launch a task to send a message, but also within the scope in which this client lives. This is for an Android project, so client would normally be a Fragment or ViewModel
s

streetsofboston

07/20/2020, 2:42 PM
You may find some help in my article. The multi-scope/lifecycle is mentioned towards the end of it. https://link.medium.com/QvcJxTLeh8
👍 1
g

gsala

07/20/2020, 4:14 PM
Interesting read. Specially the last bit about cancelling the
repoScope
not affecting the
uiScope
4 Views