Skip to content

Commit

Permalink
fix: docs and example
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Jul 2, 2024
1 parent c3e260d commit 0e66b7f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/dojo-starter
4 changes: 3 additions & 1 deletion examples/react/react-app/readme.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
## React-app
## Dojo React Vite App

[book](https://book.dojoengine.org/)
2 changes: 0 additions & 2 deletions examples/react/react-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ function App() {
const moves = useComponentValue(Moves, entityId);
const directions = useComponentValue(DirectionsAvailable, entityId);

console.log("directions", directions);

const handleRestoreBurners = async () => {
try {
await account?.applyFromClipboard();
Expand Down
1 change: 0 additions & 1 deletion examples/react/react-app/src/assets/react.svg

This file was deleted.

6 changes: 2 additions & 4 deletions examples/react/react-phaser-example/readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
## Phaser
## Dojo Phaser React App

### Instructions

When running `components` script to generate a component file, make sure to replace already given **World address** with the World Address you get after running `sozo migrate`.
[book](https://book.dojoengine.org/)
26 changes: 26 additions & 0 deletions packages/state/src/recs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import {
import { Client } from "@dojoengine/torii-client";
import { convertValues } from "../utils";

/**
* Fetches and synchronizes entities with their components.
* @param client - The client instance for API communication.
* @param components - An array of component definitions.
* @param entities - An array of entities to synchronize.
* @param limit - The maximum number of entities to fetch per request (default: 100).
* @returns A promise that resolves when synchronization is complete.
*/
export const getSyncEntities = async <S extends Schema>(
client: Client,
components: Component<S, Metadata, undefined>[],
Expand All @@ -19,6 +27,12 @@ export const getSyncEntities = async <S extends Schema>(
return await syncEntities(client, components, entities);
};

/**
* Fetches all entities and their components from the client.
* @param client - The client instance for API communication.
* @param components - An array of component definitions.
* @param limit - The maximum number of entities to fetch per request (default: 100).
*/
export const getEntities = async <S extends Schema>(
client: Client,
components: Component<S, Metadata, undefined>[],
Expand All @@ -40,6 +54,13 @@ export const getEntities = async <S extends Schema>(
}
};

/**
* Sets up a subscription to sync entity updates.
* @param client - The client instance for API communication.
* @param components - An array of component definitions.
* @param entities - An array of entities to watch for updates.
* @returns A promise that resolves with the subscription handler.
*/
export const syncEntities = async <S extends Schema>(
client: Client,
components: Component<S, Metadata, undefined>[],
Expand All @@ -50,6 +71,11 @@ export const syncEntities = async <S extends Schema>(
});
};

/**
* Updates the components of entities in the local state.
* @param entities - An array of entities with their updated component data.
* @param components - An array of component definitions.
*/
export const setEntities = async <S extends Schema>(
entities: any[],
components: Component<S, Metadata, undefined>[]
Expand Down

0 comments on commit 0e66b7f

Please sign in to comment.