jueves, 9 de septiembre de 2021

Android: Coroutines

Pieces

  • Job
  • Dispatcher
  • Scope

Job

Conceptually, a job is a cancellable thing with a life-cycle that culminates in its completion. Jobs can be arranged into parent-child hierarchies so that cancellation of a parent leads to an immediate cancellation of all its children.

Dispatcher

The dispatcher sends off coroutines to run on various threads (for example, Dispatchers.Main, Dispatchers.IO

Scope

The scope combines information, including a job and dispatcher, to define the context in which the coroutine runs.

Example (on preview)

No hay comentarios:

Publicar un comentario