@splcode/state-client
v1.2.0
Published
React hooks and socket client for Podcart state sync
Readme
@splcode/state-client
React hooks and a Socket.IO client for Podcart's control runtime.
API
import {
initializeSocket,
getSocket,
useConnectedState,
useIsConnected,
} from '@splcode/state-client';initializeSocket(url)creates the singleton Socket.IO connection.getSocket()returns the initialized client, includingsendGenericClientEvent(...).useConnectedState<T>(meter)returns[value, locked, setValue].useIsConnected()returns the live socket connection state.
Generic client events
getSocket().sendGenericClientEvent(...) is how the frontend talks to host-owned runtime endpoints such as UI layout requests, plugin events, recording commands, and mixer config requests.
const layout = await getSocket().sendGenericClientEvent({
type: 'ui-layout',
});
await getSocket().sendGenericClientEvent({
type: 'plugin-event',
deviceId: 'lighting',
pluginId: 'ShowOffPlugin',
channel: 'counter.increment',
payload: { amount: 1 },
});Host and client contract examples
- examples/root.tsx shows app bootstrap and layout loading.
- examples/recording-command.ts shows typed generic-event usage against the backend contract.
