Vize

temporal

Creates a pauseable Temporal clock whose timer follows the current Vue effect scope.

Package @vizejs/composable/temporal
Own the source vize lib pull composable:temporal
Runtime exports Temporal, TemporalIntl, useTemporalNow, useTemporalZonedDateTime
Gzip budget 2048 B

Usage

import { Temporal, TemporalIntl, useTemporalNow, useTemporalZonedDateTime } from "@vizejs/composable/temporal";

Runtime contract

Utility Category Stability SSR Hydration Cleanup Targets Host globals Uses
useTemporalNow timing experimental deterministic-fallback caller-managed reactive-scope web, server, worker, native, desktop, terminal globalThis, window —
useTemporalZonedDateTime timing experimental deterministic-fallback caller-managed reactive-scope web, server, worker, native, desktop, terminal globalThis, window useTemporalNow

API

useTemporalNow

Creates a pauseable Temporal clock whose timer follows the current Vue effect scope. The timer is replaced when reactive options change and is always cancelled when the owning scope stops. Call inside an active effect scope; without one, there is no automatic timer cleanup. During server rendering, no timer starts unless UseTemporalNowOptions.runOnServer is explicitly enabled.

function useTemporalNow(options: UseTemporalNowOptions = {}): TemporalClock

useTemporalZonedDateTime

Creates a reactive zoned date-time derived from a scoped Temporal clock. Changes to UseTemporalZonedDateTimeOptions.timeZone are reflected without replacing the underlying timer. Scheduling, server rendering, and scope-cleanup rules are shared with useTemporalNow.

function useTemporalZonedDateTime( options: UseTemporalZonedDateTimeOptions = {}, ): ComputedRef<Temporal.ZonedDateTime>

Types

TemporalScheduler

Timer host used by useTemporalNow. Implement this interface to integrate a deterministic clock, a native runtime timer, or an application-owned scheduler.

Member Type Description
setInterval (callback: () => void, intervalMs: number) => unknown Starts a repeating callback and returns its opaque cancellation handle.
clearInterval (handle: unknown) => void Cancels a handle previously returned by TemporalScheduler.setInterval.

UseTemporalNowOptions

Options for useTemporalNow.

Member Type Description
intervalMs? MaybeRefOrGetter<number> Clock update interval in milliseconds. Reactive changes replace the active timer. Values must be finite and greater than zero.
paused? MaybeRefOrGetter<boolean> Pauses periodic updates while preserving the current instant. Manual calls to TemporalClock.refresh continue to work.
runOnServer? MaybeRefOrGetter<boolean> Starts the timer when no browser window is available. Keep this disabled during server rendering. Enable it for native, desktop, worker, and test runtimes whose scheduler is lifecycle-bound.
now? () => Temporal.Instant Produces the current instant.
scheduler? TemporalScheduler Owns the repeating timer.

TemporalClock

Reactive controls returned by useTemporalNow.

Member Type Description
instant Readonly<Ref<Temporal.Instant>> The latest instant. This ref is readonly to consumers.
refresh () => Temporal.Instant Reads the clock source immediately, stores the value, and returns it.

UseTemporalZonedDateTimeOptions

Options for useTemporalZonedDateTime.

Member Type Description
intervalMs? MaybeRefOrGetter<number> Clock update interval in milliseconds. Reactive changes replace the active timer. Values must be finite and greater than zero.
paused? MaybeRefOrGetter<boolean> Pauses periodic updates while preserving the current instant. Manual calls to TemporalClock.refresh continue to work.
runOnServer? MaybeRefOrGetter<boolean> Starts the timer when no browser window is available. Keep this disabled during server rendering. Enable it for native, desktop, worker, and test runtimes whose scheduler is lifecycle-bound.
now? () => Temporal.Instant Produces the current instant.
scheduler? TemporalScheduler Owns the repeating timer.
timeZone? MaybeRefOrGetter<Temporal.TimeZoneLike> Time-zone identifier or zoned date-time accepted by Temporal.