/*! * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Microsoft Live Share SDK License. */ import React from "react"; import { IFluidLoadable } from "@fluidframework/core-interfaces"; import { LoadableObjectClass } from "fluid-framework"; import { ITimerConfig, ILiveEvent, PresenceState } from "@microsoft/live-share"; // React actions /** * Callback to set shared state */ export type SetSharedStateAction = ( state: TState | ((prevState: TState) => TState) ) => void; /** * Callback to set local state */ export type SetLocalStateAction = React.Dispatch>; // Fluid actions /** * Callback for UnregisterDDSSetStateAction. * (uniqueKey: string, componentId: string, objectClass: LoadableObjectClass, setLocalStateAction: SetLocalStateAction, onDidFirstInitialize?: (dds: T) => void) => void */ export type RegisterDDSSetStateAction = ( uniqueKey: string, componentId: string, objectClass: LoadableObjectClass, setLocalStateAction: SetLocalStateAction, onDidFirstInitialize?: (dds: T) => void ) => void; /** * Callback for UnregisterDDSSetStateAction. * (uniqueKey: string, componentId: string) => void */ export type UnregisterDDSSetStateAction = ( uniqueKey: string, componentId: string ) => void; /** * Callback for RegisterSharedSetStateAction. * (uniqueKey: string, componentId: string, setLocalStateAction: SetLocalStateAction) => void */ export type RegisterSharedSetStateAction = ( uniqueKey: string, componentId: string, setLocalStateAction: SetLocalStateAction ) => void; /** * Callback for UnregisterSharedSetStateAction. * (uniqueKey: string, componentId: string) => void */ export type UnregisterSharedSetStateAction = ( uniqueKey: string, componentId: string ) => void; /** * Callback for UpdateSharedStateAction. * (uniqueKey: string, value: any) => void */ export type UpdateSharedStateAction = (uniqueKey: string, value: any) => void; /** * Callback for DeleteSharedStateAction. * (uniqueKey: string) => void */ export type DeleteSharedStateAction = (uniqueKey: string) => void; /** * Callback for DisposeSharedStateAction. * () => void */ export type DisposeSharedStateAction = () => void; // Live Share actions /** * Callback for SetLiveStateAction. * (state: TState) => Promise */ export type SetLiveStateAction = ( state: TState | ((prevState: TState) => TState) ) => Promise; /** * Callback for SendLiveEventAction. * (event: TEvent) => Promise */ export type SendLiveEventAction = ( event: TEvent ) => Promise>; /** * Callback for OnReceivedLiveEventAction. * (event: TEvent, local: boolean) => void */ export type OnReceivedLiveEventAction = ( event: TEvent, local: boolean ) => void; /** * Callback for OnUpdateLivePresenceAction. * (data?: TData | undefined, state?: PresenceState | undefined) => Promise */ export type OnUpdateLivePresenceAction = ( data?: TData | undefined, state?: PresenceState | undefined ) => Promise; /** * Callback for OnStartTimerAction. * (duration: number) => Promise */ export type OnStartTimerAction = (duration: number) => Promise; /** * Callback for OnPlayTimerAction. * () => Promise */ export type OnPlayTimerAction = () => Promise; /** * Callback for OnPauseTimerAction. * () => Promise */ export type OnPauseTimerAction = () => Promise; /** * Callback for OnTimerTickAction. * (milliRemaining: number) => void */ export type OnTimerTickAction = (milliRemaining: number) => void; /** * Callback for OnTimerDidStartAction. * (timerConfig: ITimerConfig) => void */ export type OnTimerDidStartAction = (timerConfig: ITimerConfig) => void; /** * Callback for OnTimerDidPauseAction. * (timerConfig: ITimerConfig) => void */ export type OnTimerDidPauseAction = (timerConfig: ITimerConfig) => void; /** * Callback for OnTimerDidPlayAction. * (timerConfig: ITimerConfig) => void */ export type OnTimerDidPlayAction = (timerConfig: ITimerConfig) => void; /** * Callback for OnTimerDidFinishAction. * (timerConfig: ITimerConfig) => void */ export type OnTimerDidFinishAction = (timerConfig: ITimerConfig) => void;