dojo-state

Manage Dojo.js game state with a typed Zustand store.

37|54|Updated Sep 11, 2023
One-click install
npx skills add https://github.com/dojoengine/dojo.js --skill dojo-state
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dojo-state
Source: https://github.com/dojoengine/dojo.js/tree/main/.claude/skills/dojo-state
Command: npx skills add https://github.com/dojoengine/dojo.js --skill dojo-state

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Centralized and typed game-state management for Dojo.js using Zustand, enabling consistent entity handling and predictable updates.

Core Features & Use Cases

  • Store setup: create a typed Dojo store for entities and historical data.
  • State operations: setEntities, mergeEntities, updateEntity, and historical entity support.
  • Optimistic updates and subscriptions: apply, revert, and listen for changes.

Quick Start

Instantiate a typed Dojo store with createDojoStore and wire it into your world to begin tracking entities.

Frequently Asked Questions about dojo-state

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage Dojo.js game state with Zustand?

You can manage Dojo.js game state with Zustand by instantiating a typed Dojo store using createDojoStore and wiring it into your world to begin tracking entities, historical data, and subscriptions. This provides centralized, predictable state updates.

How do I handle optimistic updates in a Dojo.js entity store?

To handle optimistic updates in a Dojo.js entity store, you apply changes immediately to the local Zustand state, then revert or confirm them based on actual blockchain synchronization. This ensures responsive UI updates during game-state workflows.

Can I track historical entity data in a Zustand store?

Yes, you can track historical entity data in a Zustand store. The typed GameState interface includes specific methods like historicalEntities to manage and access past game-state records alongside current entity data.

What is the best way to merge entities in a Dojo.js game state?

The best way to merge entities in a Dojo.js game state is using the built-in mergeEntities method. This function combines new entity data into the existing typed Zustand store without overwriting unrelated state.

Does Dojo.js work with Zustand for typed game-state subscriptions?

Yes, Dojo.js works seamlessly with Zustand for typed game-state subscriptions. The store provides subscription utilities that allow your application to listen for and react to specific entity changes and state updates.

How do I set up a typed Dojo store for game entities?

To set up a typed Dojo store for game entities, call createDojoStore to define your GameState interface. This initializes the environment for setEntities, updateEntity, and subscription operations within your Dojo.js application.