Skip to content

Commit

Permalink
chore: type cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Jul 7, 2024
1 parent 91a7e75 commit 4066fb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
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 @@ -5,8 +5,6 @@ import "./App.css";
import { Direction } from "./utils";
import { getEntityIdFromKeys } from "@dojoengine/utils";
import { useDojo } from "./dojo/useDojo";
import { getSyncEntities } from "@dojoengine/state";
import { Subscription } from "@dojoengine/torii-client";

function App() {
const {
Expand Down
14 changes: 7 additions & 7 deletions packages/state/src/recs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,27 @@ export const getEntities = async <S extends Schema>(
/**
* Fetches all entities and their components from the client.
* @param client - The client instance for API communication.
* @param entities - An optional EntityKeysClause to filter entities.
* @param entityKeyClause - An optional EntityKeysClause to filter entities.
* @param components - An array of component definitions.
* @param limit - The maximum number of entities to fetch per request (default: 100).
*/
export const getEntitiesQuery = async <S extends Schema>(
client: Client,
components: Component<S, Metadata, undefined>[],
entities: EntityKeysClause | undefined,
entityKeyClause: EntityKeysClause | undefined,
limit: number = 1000
) => {
let cursor = 0;
let continueFetching = true;

while (continueFetching) {
const clause: Clause | null = entities
const clause: Clause | null = entityKeyClause
? {
Keys: {
keys:
"HashedKeys" in entities
? entities.HashedKeys
: entities.Keys.keys,
"HashedKeys" in entityKeyClause
? entityKeyClause.HashedKeys
: entityKeyClause.Keys.keys,
pattern_matching: "FixedLen",
models: [
...components.map(
Expand Down Expand Up @@ -108,7 +108,7 @@ export const getEntitiesQuery = 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.
* @param entityKeyClause - An optional EntityKeysClause to filter entities.
* @returns A promise that resolves with the subscription handler.
*/
export const syncEntities = async <S extends Schema>(
Expand Down

0 comments on commit 4066fb7

Please sign in to comment.