Vsevolod Tolstopyatov | d57bfa2 | 2019-04-04 14:25:13 +0300 | [diff] [blame] | 1 | /* |
Aurimas Liutikas | 79e555e | 2021-05-17 17:41:41 +0000 | [diff] [blame] | 2 | * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
Vsevolod Tolstopyatov | d57bfa2 | 2019-04-04 14:25:13 +0300 | [diff] [blame] | 3 | */ |
| 4 | |
| 5 | package kotlinx.coroutines.flow |
| 6 | |
Vsevolod Tolstopyatov | d57bfa2 | 2019-04-04 14:25:13 +0300 | [diff] [blame] | 7 | /** |
| 8 | * [FlowCollector] is used as an intermediate or a terminal collector of the flow and represents |
| 9 | * an entity that accepts values emitted by the [Flow]. |
| 10 | * |
Yanis Batura | 563b7e5 | 2019-05-06 09:24:27 +0700 | [diff] [blame] | 11 | * This interface should usually not be implemented directly, but rather used as a receiver in a [flow] builder when implementing a custom operator. |
Vsevolod Tolstopyatov | d57bfa2 | 2019-04-04 14:25:13 +0300 | [diff] [blame] | 12 | * Implementations of this interface are not thread-safe. |
| 13 | */ |
Vsevolod Tolstopyatov | 61c64cc | 2019-04-12 16:05:58 +0300 | [diff] [blame] | 14 | public interface FlowCollector<in T> { |
Vsevolod Tolstopyatov | d57bfa2 | 2019-04-04 14:25:13 +0300 | [diff] [blame] | 15 | |
| 16 | /** |
| 17 | * Collects the value emitted by the upstream. |
Vsevolod Tolstopyatov | 15ee8a3 | 2019-05-29 21:27:22 +0300 | [diff] [blame] | 18 | * This method is not thread-safe and should not be invoked concurrently. |
Vsevolod Tolstopyatov | d57bfa2 | 2019-04-04 14:25:13 +0300 | [diff] [blame] | 19 | */ |
| 20 | public suspend fun emit(value: T) |
| 21 | } |