1.1 KiB
1.1 KiB
name, description, license, triggers
| name | description | license | triggers | |||
|---|---|---|---|---|---|---|
| action-dispatcher | Implements store actions for social behaviors (toggleEndorsement, toggleLike, requestEndorsement) and keeps logic testable. | MIT |
|
Action Dispatcher
When to use this skill
- Use when adding or changing business logic inside Zustand stores or when moving UI logic into testable actions.
- Triggered by prompts about endorsement toggles, likes, and user profile updates.
Instructions
-
First Step: Implement pure functions for actions where possible (e.g.,
addEndorsement(state, payload) => newState). -
Second Step: Hook these functions into the store actions so they can be unit-tested separately from UI.
-
Third Step: Add unit tests for each action and ensure edge cases (duplicate endorsements, idempotency) are handled.
Examples
toggleLike(paperId, userId)checks current likes and adds/removes the user id.
Notes
- Keep action functions deterministic and avoid direct DOM or side-effect operations inside them; delegate I/O to services.