- Home
- Skills
- Reactive
- Data Client
- Data Client Manager
data-client-manager_skill
- TypeScript
2k
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill reactive/data-client --skill data-client-manager- SKILL.md4.9 KB
Overview
This skill implements @data-client Managers to handle global side effects for async state management in TypeScript. It provides a pattern for centralizing websockets, Server-Sent Events, polling, subscriptions, logging, middleware, and controller-driven actions across your app. Managers live as singletons and integrate with the controller and redux-style middleware to run and react to actions.
How this skill works
Managers expose a middleware function that receives a Controller and returns a redux-style middleware to intercept actions. Use the Controller API (dispatchers and accessors) to trigger fetches, set responses, subscribe/unsubscribe, read store state, and perform imperatively controlled updates. Managers also provide a cleanup lifecycle to stop intervals, close sockets, or tear down other side effects.
When to use it
- You need a single place to manage long-lived side effects (websockets, SSE, polling).
- You want centralized logging or analytics triggered by store actions.
- You need to translate SUBSCRIBE/UNSUBSCRIBE actions into external subscriptions or channels.
- You must perform periodic updates or background refresh using controller.set or controller.fetch.
- You want middleware-like behavior that can read state and decide whether to consume an action.
Best practices
- Always compare action.type using the provided actionTypes constants to avoid string mismatches.
- Perform external side-effect setup in middleware(controller) so you can access controller methods and state.
- Call next(action) for actions you do not fully consume; return a resolved Promise if you fully handle an action.
- Use controller.getResponse/getState/getError/snapshot to read the latest store before making decisions.
- Implement cleanup to clear timers, close sockets, and release resources when the manager is torn down.
Example use cases
- A TimeManager that sets a central CurrentTime resource every second using controller.set.
- A LoggingManager that logs SET_RESPONSE payloads and then reads the finalized data from the store.
- A WebsocketManager that opens a socket on SUBSCRIBE, routes incoming messages to controller.setResponse, and closes on UNSUBSCRIBE.
- A PollingManager that dispatches controller.fetchIfStale on an interval and invalidates stale cache entries.
- A CustomSubsManager that maps application-level subscriptions to external channels and prevents other managers from handling those actions.
FAQ
Use controller.getResponse, controller.getState, or controller.snapshot to read the latest store data inside your middleware before dispatching actions.
When should a manager consume an action instead of passing it on?
Consume actions when the manager fully handles the side effect (e.g., opening a socket for SUBSCRIBE) and no further processing is needed; otherwise call next(action) so other managers and reducers can process it.