server-state-sync
Version:
State synchronization between multiple clients
12 lines (11 loc) • 614 B
TypeScript
import State, { StateConfiguration } from './State';
import SocketClient from './SocketClient';
export default class StateManager<T, K> {
states: Map<string, State<T, K>>;
addState: (config: StateConfiguration<T, K>, identifier?: string | undefined) => string | null;
removeState: (identifier: string) => boolean;
connectToState: (socketClient: SocketClient<T, K>, stateIdentifier: string) => void;
getStateValue(stateIdentifier: string): T | undefined;
mutateState(stateIdentifier: string, updates: Partial<T>, clientInformation: K): Boolean;
removeAllStates: () => void;
}