Skip to content

Repeat With Delay

Ivan Kasenkov edited this page Dec 22, 2021 · 4 revisions

https://codesandbox.io/s/ksrepeatwithdelay-7khd5

ksRepeatWithDelay.ts

import { ksDelay, ksRepeatWhen, Transformer } from '@keiii/k-stream';

/**
 * Perform some action regularly with specific delay between.
 */
export const ksRepeatWithDelay = <A>(ms: number): Transformer<A, A> => {
  return stream => stream.pipe(ksRepeatWhen(x => x.pipe(ksDelay(ms))));
};
Clone this wiki locally