blob: d1c1565cb0863ddebb753303c351787ab5b1b04a [file] [log] [blame]
Vsevolod Tolstopyatovd57bfa22019-04-04 14:25:13 +03001/*
Aurimas Liutikas79e555e2021-05-17 17:41:41 +00002 * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
Vsevolod Tolstopyatovd57bfa22019-04-04 14:25:13 +03003 */
4
5package kotlinx.coroutines.flow
6
Vsevolod Tolstopyatovd57bfa22019-04-04 14:25:13 +03007/**
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 Batura563b7e52019-05-06 09:24:27 +070011 * This interface should usually not be implemented directly, but rather used as a receiver in a [flow] builder when implementing a custom operator.
Vsevolod Tolstopyatovd57bfa22019-04-04 14:25:13 +030012 * Implementations of this interface are not thread-safe.
13 */
Vsevolod Tolstopyatov61c64cc2019-04-12 16:05:58 +030014public interface FlowCollector<in T> {
Vsevolod Tolstopyatovd57bfa22019-04-04 14:25:13 +030015
16 /**
17 * Collects the value emitted by the upstream.
Vsevolod Tolstopyatov15ee8a32019-05-29 21:27:22 +030018 * This method is not thread-safe and should not be invoked concurrently.
Vsevolod Tolstopyatovd57bfa22019-04-04 14:25:13 +030019 */
20 public suspend fun emit(value: T)
21}