UNPKG

@croquet/react

Version:

React bindings for Croquet

34 lines (33 loc) 1.11 kB
import { View } from '@croquet/croquet'; import { ReactModel } from './ReactModel'; export type UpdateCallback = (time: number) => void; export type SyncedCallback = (flag: boolean) => void; export type DetachCallback = () => void; export declare class CroquetReactView<M extends ReactModel> extends View { model: M; updateCallback: UpdateCallback | null; syncedCallback: SyncedCallback | null; detachCallback: DetachCallback | null; constructor(model: M); update(time: number): void; synced(flag: boolean): void; detach(): void; } /** A function to set up the handler for the synced event. * It is supposed to be called from the React component that * calls createReactSession() in the following manner from where the * *``` *setSyncedCallback((flag) => { * console.log(`synced`, flag) * if (flag) { * setCroquetView((old) => session.view) * } * session.view.detachCallback = () => { * console.log(`detached`) * setCroquetView(null) * } *}) *``` */ export declare function setSyncedCallback(func: (flag: boolean) => void): void;