StreamSource

interface StreamSource<T> : Stream<T>

Define a stream source to which new values can be written.

Inheritors

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun <T> Stream<T>.asFlow(): Flow<T>

Converts the Stream into a Flow

Link copied to clipboard
fun <IN1, IN2, OUT> Stream<IN1>.combinedWith(other: Stream<IN2>, combinator: (IN1, IN2) -> OUT): Stream<OUT>

Combines with the other stream.

Link copied to clipboard
fun <T> Stream<T>.debounce(delayMs: Int, delayFirstMs: Int = 3): Stream<T>

Debounce the incoming values by the given delayMs

Link copied to clipboard
fun <T> Stream<T>.distinct(): Stream<T>
fun <T> Stream<T>.distinct(strict: Boolean = false): Stream<T>

Ignores duplicate values and thus only publishes when the value has changed.

Link copied to clipboard

Ignores duplicate values and thus only publishes when the value has changed.

Link copied to clipboard
fun <T> Stream<T?>.fallbackBy(fallback: () -> T): Stream<T>

Published the value produced by fallback whenever the value on the stream is null.

Link copied to clipboard
fun <T> Stream<T?>.fallbackTo(fallback: T): Stream<T>

Published the fallback whenever the value on the stream is null.

Link copied to clipboard
fun <T> Stream<T>.filter(predicate: (T) -> Boolean): Stream<T?>
fun <T> Stream<T>.filter(initial: T, predicate: (T) -> Boolean): Stream<T>

Filter the incoming values and publish only the ones that match the predicate.

Link copied to clipboard
inline fun <T, I : T> Stream<T?>.filterIsInstance(): Stream<I?>
inline fun <T, I : T> Stream<T?>.filterIsInstance(initial: I): Stream<I>

Filters the incoming values and publish only the ones that are an instance of I.

Link copied to clipboard
fun <T> Stream<T?>.filterNotNull(initial: T): Stream<T>

Filter out all null values.

Link copied to clipboard
fun <T, R> Stream<T>.fold(initial: R, operation: (acc: R, next: T) -> R): Stream<R>

Folds the incoming values with the operation starting with the initial value.

Link copied to clipboard
fun <T, R> Stream<T?>.foldNotNull(initial: R, operation: (acc: R, next: T) -> R): Stream<R>
Link copied to clipboard
fun <T> Stream<T>.history(capacity: Int): Stream<List<T>>

Records the latest incoming values up to the given capacity.

Link copied to clipboard
fun <T> Stream<T?>.historyOfNonNull(capacity: Int): Stream<List<T>>

Records the latest incoming values that are not null up to the given capacity.

Link copied to clipboard
fun <T> Stream<T>.indexed(): Stream<Pair<Int, T>>

Map the stream to pairs of index to value.

Link copied to clipboard
abstract operator override fun invoke(): T

Returns the current value of the stream

abstract operator fun invoke(next: T)

Sends the next value to the stream

open operator fun invoke(block: (T) -> T)

Calls the block with the current value of the stream and sends to return value to the stream.

Link copied to clipboard
fun <IN, OUT> Stream<IN>.map(mapper: (IN) -> OUT): Stream<OUT>

Maps incoming values from type IN to type OUT.

Link copied to clipboard
fun <IN, OUT> Stream<IN>.mapAsync(mapper: suspend (IN) -> OUT?): Stream<OUT?>

Maps incoming values asynchronously from type IN to type OUT.

Link copied to clipboard
open fun modify(block: T.() -> T)

Modifies the current value by calling the block and sends it the result as the next value.

Link copied to clipboard
fun <T> Stream<T>.onEach(block: (T) -> Unit): Stream<T>
Link copied to clipboard

Pairs the stream with the other stream.

Link copied to clipboard
fun <T> Stream<T>.permanent(): Stream<T>
fun <T> Stream<T>.permanent(handler: (T) -> Unit): Stream<T>

Subscribes to the stream permanently

Link copied to clipboard
fun <T> StreamSource<T>.persistInLocalStorage(key: String, serializer: KSerializer<T>, codec: Json = defaultJson): StreamSource<T>

Converts a StreamSource so that it will persist its values in the local storage under the given key.

Link copied to clipboard
abstract fun removeAllSubscriptions()

Removes all subscriptions

Link copied to clipboard
abstract fun subscribeToStream(sub: (T) -> Unit = {}): Unsubscribe

Adds a subscription to the stream.

Properties

Link copied to clipboard
open val readonly: Stream<T>

Get the readonly version of this stream.

Link copied to clipboard

The subscription the stream source has.