Skip to main

ofScheduled

ofScheduled

Signature - source.ts#L787

function ofScheduled<T>(schedule: ScheduleFunction, ...items: T[]): Source<T>

Creates a source which will emit the given items according to the given schedule function. For example, if the schedule function acts as a 1s interval then the items will be emitted on a 1s interval.

Parameters

ParameterTypeDescription
schedule
ScheduleFunction

The schedule function.

items
T[]

The items to schedule.

Returns

TypeDescription
Source<T>

The created source.

Example Usage

import {
    ofScheduled,
    ScheduleInterval,
    pipe,
    subscribe
} from '@microstream/core';

const scheduleFunction = ScheduleInterval(1000);
pipe(
    ofScheduled(scheduleFunction, 2, 4, 6),
    subscribe(console.log)
)
// 1s -> Push(2)
// 2s -> Push(4)
// 3s -> Push(6), End

See Also