Redux Toolkit server-data layer for Sockatrice-based webclients (Cockatrice ecosystem).
Datatrice owns the server data slices of a Cockatrice webclient's Redux store: server, rooms, and games. It also internalizes the Sockatrice-to-store bridge (the *ResponseImpl classes), so consumers can wire a WebClient to a store in one call:
import { createStore, attachResponseHandlers, server } from '@cockatrice/datatrice';
import { WebClient } from '@cockatrice/sockatrice';
const store = createStore();
const client = new WebClient(attachResponseHandlers(store), CLIENT_CONFIG, CLIENT_OPTIONS);
const buddies = server.selectors.selectBuddyList(store.getState());Distributed as a .tgz via GitHub Releases (no npm registry):
npm install https://github.com/Cockatrice/Datatrice/releases/download/v1.0.0/cockatrice-datatrice-1.0.0.tgzYou also need to install Sockatrice (peer dependency) and @reduxjs/toolkit.
createStore(options?)— returns a configured RTK store with listeners pre-registered.rootReducer— for consumers embedding Datatrice in a largercombineReducers.attachResponseHandlers(store)— returns aWebsocketTypes.IWebClientResponsewired to the given store.isSerializable,storeMiddlewareOptions— protobuf-tolerant middleware helpers.server,rooms,games— per-slice{ actions, selectors }namespaces.
Opt-in React glue via @cockatrice/datatrice/react:
<StoreProvider store={...}>—react-reduxwrapper.useAppSelector,useAppDispatch— typed hooks.
Re-exported Sockatrice types via @cockatrice/datatrice/types.
GPL-2.0-or-later. See LICENSE.