Skip to content

mostjs-community/virtual-scheduler

Repository files navigation

most-virtual-scheduler

This package is home to an alternative Clock and Timer implementation that use "virtual" time to progress @most/cores Scheduler forward imperatively and with precise control. This is designed for testing scenarios, where real asynchrony is either too slow or hard to test.

Install

# NPM
npm i --save most-virtual-scheduler
# Yarn
yarn add most-virtual-scheduler

Usage

import { createVirtualScheduler } from 'most-virtual-scheduler'

// Construct our VirtualTimer-Scheduler pair
const [timer, scheduler] = createVirtualScheduler()

// Construct a stream
const stream = ... 

// Run your stream
runEffects(stream, scheduler)

// Manually "progress" time by 100 milliseconds
// All tasks scheduled to be run between 0 and 100 will be run
// in the order they were scheduled.
timer.progressTimeBy(100)

About

A Scheduler instance useful for testing

Resources

Stars

Watchers

Forks

Packages

No packages published