Skip to content

Vizel API / core/src / createVizelRelativeTimeTicker

Function: createVizelRelativeTimeTicker()

ts
function createVizelRelativeTimeTicker(options): VizelRelativeTimeTicker;

Defined in: packages/core/src/controllers/relativeTimeTicker.ts:52

Build a relative-time interval ticker.

The factory itself has no side effects. mount() calls onTick synchronously with the current relative-time string, then on every intervalMs boundary until unmount() clears the interval.

Parameters

ParameterType
optionsVizelRelativeTimeTickerOptions

Returns

VizelRelativeTimeTicker

Example

tsx
// React adapter:
useEffect(() => {
  const ticker = createVizelRelativeTimeTicker({
    getDate: () => date,
    onTick: setText,
  });
  ticker.mount();
  return () => ticker.unmount();
}, []);

Released under the MIT License.