Skip to content

Commit

Permalink
fix(recs): fix fragment types in system definitions (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kooshaba authored Jul 26, 2022
1 parent fcb0be8 commit c74f393
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions packages/recs/src/Query.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { filterNullish } from "@latticexyz/utils";
import { observable, ObservableSet } from "mobx";
import { concat, concatMap, EMPTY, filter, from, map, merge, Observable, of, switchMap } from "rxjs";
import { concat, concatMap, filter, from, map, merge, Observable, of } from "rxjs";
import {
componentValueEquals,
getComponentEntities,
Expand Down Expand Up @@ -337,7 +337,7 @@ export function defineQuery(
* @returns Stream of component updates of entities that had already matched the query
*/
export function defineUpdateQuery(
fragments: EntityQueryFragment[],
fragments: QueryFragment[],
options?: { runOnInit?: boolean }
): Observable<ComponentUpdate & { type: UpdateType }> {
return defineQuery(fragments, options).update$.pipe(filter((e) => e.type === UpdateType.Update));
Expand All @@ -348,7 +348,7 @@ export function defineUpdateQuery(
* @returns Stream of component updates of entities matching the query for the first time
*/
export function defineEnterQuery(
fragments: EntityQueryFragment[],
fragments: QueryFragment[],
options?: { runOnInit?: boolean }
): Observable<ComponentUpdate> {
return defineQuery(fragments, options).update$.pipe(filter((e) => e.type === UpdateType.Enter));
Expand All @@ -359,7 +359,7 @@ export function defineEnterQuery(
* @returns Stream of component updates of entities not matching the query anymore for the first time
*/
export function defineExitQuery(
fragments: EntityQueryFragment[],
fragments: QueryFragment[],
options?: { runOnInit?: boolean }
): Observable<ComponentUpdate> {
return defineQuery(fragments, options).update$.pipe(filter((e) => e.type === UpdateType.Exit));
Expand Down
12 changes: 6 additions & 6 deletions packages/recs/src/System.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { concat, EMPTY, from, Observable } from "rxjs";
import { getComponentEntities, removeComponent, setComponent } from "./Component";
import { UpdateType } from "./constants";
import { defineEnterQuery, defineExitQuery, defineQuery, defineUpdateQuery } from "./Query";
import { Component, ComponentUpdate, ComponentValue, EntityIndex, EntityQueryFragment, Schema, World } from "./types";
import { Component, ComponentUpdate, ComponentValue, EntityIndex, QueryFragment, Schema, World } from "./types";
import { toUpdateStream } from "./utils";

export function defineRxSystem<T>(world: World, observable$: Observable<T>, system: (event: T) => void) {
Expand All @@ -12,7 +12,7 @@ export function defineRxSystem<T>(world: World, observable$: Observable<T>, syst

export function defineUpdateSystem(
world: World,
query: EntityQueryFragment[],
query: QueryFragment[],
system: (update: ComponentUpdate) => void,
options: { runOnInit?: boolean } = { runOnInit: true }
) {
Expand All @@ -21,7 +21,7 @@ export function defineUpdateSystem(

export function defineEnterSystem(
world: World,
query: EntityQueryFragment[],
query: QueryFragment[],
system: (update: ComponentUpdate) => void,
options: { runOnInit?: boolean } = { runOnInit: true }
) {
Expand All @@ -30,7 +30,7 @@ export function defineEnterSystem(

export function defineExitSystem(
world: World,
query: EntityQueryFragment[],
query: QueryFragment[],
system: (update: ComponentUpdate) => void,
options: { runOnInit?: boolean } = { runOnInit: true }
) {
Expand All @@ -39,7 +39,7 @@ export function defineExitSystem(

export function defineSystem(
world: World,
query: EntityQueryFragment[],
query: QueryFragment[],
system: (update: ComponentUpdate & { type: UpdateType }) => void,
options: { runOnInit?: boolean } = { runOnInit: true }
) {
Expand All @@ -65,7 +65,7 @@ export function defineComponentSystem<S extends Schema>(
*/
export function defineSyncSystem<T extends Schema>(
world: World,
query: EntityQueryFragment[],
query: QueryFragment[],
component: (entity: EntityIndex) => Component<T>,
value: (entity: EntityIndex) => ComponentValue<T>,
options: { update?: boolean; runOnInit?: boolean } = { update: false, runOnInit: true }
Expand Down

0 comments on commit c74f393

Please sign in to comment.