Skip to content

flowOn(Dispatchers.Main) does not change upstream dispatcher #3545

Closed
@hoc081098

Description

@hoc081098
    flowOf(1)
      .onEach {
        Timber.d("timer: $it ${Thread.currentThread().name} ${currentCoroutineContext()[ContinuationInterceptor]}")
      }
      .flowOn(Dispatchers.Main)
      .onEach {
        Timber.d("timer [1]: $it ${Thread.currentThread().name} ${currentCoroutineContext()[ContinuationInterceptor]}")
      }
      .launchIn(viewModelScope)

// viewModelScope's context is SupervisorJob() + Dispatchers.Main.immediate

Console

timer: 1 main Dispatchers.Main.immediate
timer [1]: 1 main Dispatchers.Main.immediate

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions