RTCForge API Reference v1.1.1
    Preparing search index...

    Interface Clock

    Abstraction over time and timers.

    Components that need the current time or need to schedule work take a Clock rather than calling Date.now / setTimeout directly. In production pass systemClock; in tests pass a ManualClock to advance time deterministically.

    interface Clock {
        clearTimeout(handle: unknown): void;
        now(): number;
        setTimeout(fn: () => void, ms: number): unknown;
    }

    Implemented by

    Index

    Methods

    • Cancels a timer previously created with setTimeout.

      Parameters

      • handle: unknown

        The handle returned by setTimeout.

      Returns void

    • Schedules fn to run after approximately ms milliseconds.

      Parameters

      • fn: () => void

        The callback to invoke when the delay elapses.

      • ms: number

        Delay in milliseconds.

      Returns unknown

      An opaque handle that can be passed to clearTimeout.