July 2018
Intermediate to advanced
266 pages
7h 11m
English
As we discussed earlier in the book, the CoroutineContext behaves like a map where all the different CoroutineContext.Element are stored with their own unique key. One of those elements is defined by the ContinuationInterceptor interface. Let's take a look at it:
public interface ContinuationInterceptor : CoroutineContext.Element { companion object Key : CoroutineContext.Key<ContinuationInterceptor> fun <T> interceptContinuation(cont: Continuation<T>): Continuation<T>}
Notice that apart from its key, it only defines a function that takes a continuation and returns another. The idea is for the implementation of ContinuationInterceptor to wrap the received continuation into another, one that is intercepted in order to ...
Read now
Unlock full access