Package de.peekandpoke.kraft.streams.addons

Types

Link copied to clipboard
class LocalStorageStreamStorage<T>(    toStr: (T) -> String,     fromStr: (String?) -> T?,     storageKey: String) : StreamStorage<T>

Functions

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 debouncedFunc(delayMs: Int = 200, block: () -> Unit): () -> Unit
Link copied to clipboard
fun debouncedFuncExceptFirst(delayMs: Int = 200, block: () -> Unit): () -> Unit
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
fun <T> Stream<T>.distinctStrict(): Stream<T>

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: (R, 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: (R, 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
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
fun <T> Stream<T>.onEach(block: (T) -> Unit): Stream<T>
Link copied to clipboard
fun <IN1, IN2> Stream<IN1>.pairedWith(other: Stream<IN2>): Stream<Pair<IN1, IN2>>

Pairs the stream with the other stream.

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
fun ticker(intervalMs: Int): Stream<Long>