So far, we have discussed and implemented suspending functions in one way: as functions that suspend while waiting for the execution of one or more computations to happen. A simple representation of this is as follows:
In this example, getProfile starts its execution and, soon after, it suspends to wait for fetchProfile to execute. Once the response has been processed, getProfile suspends once more, this time to call calculateAge. When calculateAge finishes, the execution of getProfile continues until completion.
In this chapter, we will cover a different scenario: writing functions that are suspended between executions. For example, we can have a repository that is suspended until the next page is required:
In the previous example, the next() function will yield the first element from the data source, and will suspend immediately after returning...