I have recently <read an article> which suggests that SupervisorJob shouldn't be used and Coroutine...
d
I have recently read an article which suggests that SupervisorJob shouldn't be used and CoroutineScope with proper try/catch (which is more mallable for your usecase) should be used instead (see SupervisorJob section there). On one hand I find this is true, but I still keep thinking that SupervisorJob is useful in scenarios where you specifically manage some task-like coroutine executions. What do you think?
f
Depends on your use case. With supervisor job a child won't cancel other children and the parent, so other coroutines continue to run and you can launch more on the parent scope.
d
I know. But this can be done manually too with proper try/catch which is discussed in the article among other points.
n
It's basically saying “You can implement it yourself so don't bother using the built in solution” which is awful advice. It’s also error prone to require every task to implement the try/catch in order just to reimplement supervisor behavior.
f
It's a call you have to make. I disagree with that article that you should never use supervisor scope, I think there are valid uses cases for it. Ultimately use what best works for you and use these blogs as guidance and not as gospel.
d
Nice, so I'm not alone in thinking this might be too radical to advise against it completely 🙂
But the point that "if you get passed a scope, you actually don't know if its supervisor scope or not, so you'll have to assume it isn't" is a valid point and should be taken into account in some designs, it's a good thing author mentioned it.