export const debounceWithTimeout =
(debounceDuration: Duration.Duration, maxTimeout: Duration.Duration) =>
<A, E, R>(self: Stream.Stream<A, E, R>) => {
const make = (): Stream.Stream<A, E, R> =>
self.pipe(
Stream.debounce(debounceDuration),
Stream.timeoutTo(
maxTimeout,
self.pipe(
Stream.take(1),
Stream.concat(Stream.make(1).pipe(Stream.flatMap(make)))
)
)
);
return make();
};
export const debounceWithTimeout =
(debounceDuration: Duration.Duration, maxTimeout: Duration.Duration) =>
<A, E, R>(self: Stream.Stream<A, E, R>) => {
const make = (): Stream.Stream<A, E, R> =>
self.pipe(
Stream.debounce(debounceDuration),
Stream.timeoutTo(
maxTimeout,
self.pipe(
Stream.take(1),
Stream.concat(Stream.make(1).pipe(Stream.flatMap(make)))
)
)
);
return make();
};