/*! * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Microsoft Live Share SDK License. */ import { UserMeetingRole } from "@microsoft/live-share"; import { IUseLiveTimerResults, OnTimerDidFinishAction, OnTimerDidPauseAction, OnTimerDidPlayAction, OnTimerDidStartAction, OnTimerTickAction } from "../types/index.js"; /** * React hook for using Live Share's `LiveTimer` DDS. * * @remarks * Use this hook to create a synchronized countdown timer in your app or to schedule synchronized tasks. * This hook can only be used in a child component of `` or ``. * * @param uniqueKey the unique key for the `LiveTimer`. If one does not yet exist, a new one will be created, otherwise it will use the existing one. * @param allowedRoles Optional. the user roles that are allowed to start/stop/pause the timer. * @param tickRate Optional. the interval in which the `milliRemaining` state should be updated and the `onTick` callback will trigger. * @param onTick Optional. event handler callback for when an active timer ticks. * @param onStart Optional. event handler callback for when the timer is started. * @param onPause Optional. event handler callback for when the timer is paused. * @param onPlay Optional. event handler callback for when the timer is resumed. * @param onFinish Optional. event handler callback for when the timer finishes. * @returns results and callbacks exposed via the hook. * * @example ```jsx import { useLiveTimer } from "@microsoft/live-share-react"; // Define a unique key that differentiates this usage of `useLiveTimer` from others in your app const MY_UNIQUE_KEY = "timer-key"; // Example component for using useLiveTimer export function CountdownTimer() { const { milliRemaining, timerConfig, liveTimer, start, pause, play, } = useLiveTimer("TIMER-ID"); // Render loading UI when creating LiveTimer instance for first time if (!liveTimer) return <>Loading...; return (
{timerConfig !== undefined && ( )} {milliRemaining !== undefined && (

{`${Math.round(milliRemaining / 1000)} / ${ Math.round(timerConfig.duration) / 1000 }`}

)}
); } ``` */ export declare function useLiveTimer(uniqueKey: string, allowedRoles?: UserMeetingRole[], tickRate?: number, onTick?: OnTimerTickAction, onStart?: OnTimerDidStartAction, onPause?: OnTimerDidPauseAction, onPlay?: OnTimerDidPlayAction, onFinish?: OnTimerDidFinishAction): IUseLiveTimerResults; //# sourceMappingURL=useLiveTimer.d.ts.map