/*! * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Microsoft Live Share SDK License. */ import { UserMeetingRole } from "@microsoft/live-share"; import { IUseLiveEventResults, OnReceivedLiveEventAction } from "../types/index.js"; /** * React hook for using a Live Share `LiveEvent`. * * @remarks * Use this hook if you want to send transient JSON objects to everyone connected to the Fluid container, * such as when sending push notifications or reactions. * This hook can only be used in a child component of `` or ``. * * @template TEvent Optional typing for events sent & received. Default is `object` type. * @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one * will be created, otherwise it will use the existing one. * @param allowedRoles Optional. The meeting roles eligible to send events through this object. * @param onReceivedEvent Optional. Callback method to be called when a new notification is received. * @returns stateful `latestEvent` & `allEvents` list, `sendEvent` callback, and the `liveEvent` object. * * @example ```jsx import { useLiveEvent } from "@microsoft/live-share-react"; const emojis = ["❤️", "😂", "👍", "👎"]; // Define a unique key that differentiates this usage of `useLiveEvent` from others in your app const MY_UNIQUE_KEY = "event-key"; // Example component for using useLiveEvent export const MyCustomEvent = () => { const { latestEvent, liveEvent, sendEvent } = useLiveEvent(MY_UNIQUE_KEY); // Render loading UI when creating LiveEvent instance for first time if (!liveEvent) return <>Loading...; // Render UI return (
{`Latest event: ${latestEvent?.value}, from local user: ${latestEvent?.local}`} {"Select a planet below:"} {emojis.map((emoji) => ( ))}
); }; ``` */ export declare function useLiveEvent(uniqueKey: string, allowedRoles?: UserMeetingRole[], onReceivedEvent?: OnReceivedLiveEventAction): IUseLiveEventResults; //# sourceMappingURL=useLiveEvent.d.ts.map