Allan Wang
10/16/2018, 6:04 PMCancellationException
will cancel the parent no matter what, so do we have to wrap our code in a try catch?
To be more specific, this is the problem I want to solve:
I have a method that takes in an id and returns an auth object
I have other methods that will take in an auth object and then output something else
I want to create a running stream for the duration of my lifecycle that will take in ids and actions. If an auth does not exist (say in a map), I want to fetch it. Once an auth is fetched, I want to run any pending actions on that auth. If an auth is being fetched and another request is made requiring that auth, it should wait for the previous fetch rather than getting a new auth itself. This pattern is already shown in the talk using Map<T, List<K>>
. If the auth fetch fails, I want to cancel any pending actions. If an action fails, or anything else outside of this scope, I want the CoroutineScope
to stay alive, until it is cancelled by the lifecycle.elizarov
10/16/2018, 6:31 PM