android-components / mozilla.components.support.base.observer / ConsumableStream

ConsumableStream

class ConsumableStream<T> (source)

A generic wrapper for a stream of values that can be consumed. Values will be consumed first in, first out.

Functions

Name Summary
append fun append(vararg values: T): ConsumableStream<T>
Copies the stream and appends the provided values.
consumeAll fun consumeAll(consumer: (value: T) -> Boolean): Boolean
Invokes the given lambda for each consumable value and marks the values as consumed if the lambda returns true.
consumeAllBy fun consumeAllBy(consumers: List<(T) -> Boolean>): Boolean
Invokes the given list of lambdas for each consumable value and marks the values as consumed if at least one lambda returns true.
consumeNext fun consumeNext(consumer: (value: T) -> Boolean): Boolean
Invokes the given lambda with the next consumable value and marks the value as consumed if the lambda returns true.
consumeNextBy fun consumeNextBy(consumers: List<(T) -> Boolean>): Boolean
Invokes the given list of lambdas with the next consumable value and marks the value as consumed if at least one lambda returns true.
isConsumed fun isConsumed(): Boolean
Returns true if all values in this stream were consumed, otherwise false.
isEmpty fun isEmpty(): Boolean
Returns true if the stream is empty, otherwise false.
remove fun remove(value: T): ConsumableStream<T>
Copies the stream but removes all consumables equal to the provided value.
removeConsumed fun removeConsumed(): ConsumableStream<T>
Copies the stream but removes all consumed values.

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.