fn throttle
Keeps the first element of every interval of d, drops the rest.
Example:
use std.stream { throttle }
fn nums() -> stream<i32> {
for i in 1..=3 { yield i }
}
fn main() io, time {
var out: List<i32> = []
// all three arrive within the interval: only the first passes
for await x in nums() |> throttle(1h) {
out.push(x)
}
print("{out}")
}Output
[1]
pub(api) fn throttle<T, E>(s: stream<T, E>, d: Duration) -> stream<T, E> timeComplexity. O(1) per element.
Since. 1.0.0-beta
Parameters
Returns
stream<T, E>
Effects
time
Defined in: std/stream/stream.oxl:451