Question regarding withContext; perhaps we're usin...
# announcements
d
Question regarding withContext; perhaps we're using it incorrectly We are injected some thread context into the call and running a block of code with that injected thread context, so something like
Copy code
withContext(InjectThreadContext(...)) {
    //doStuff
    //otherStuff
    //moreStuff
}
So this works in the sense that when the coroutine resumes/starts it'll inject our thread context and right after it suspends we have it restore the original context by closing our injected context. But once we reach the end there is no suspend again so the injected context then leaks out of the block whereas we want it to do like a final close. Is there a different method we should be using?
g
#coroutines is probably better channel for this
What is InjectThreadContext?
withContext will just pass context to receiver scope and to every suspend function. so nothing complicated in terms of how it should be used