-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(recs,std-client): move action system to recs (#1351)
Co-authored-by: alvrs <alvarius@lattice.xyz>
- Loading branch information
Showing
26 changed files
with
224 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
"@latticexyz/recs": minor | ||
"@latticexyz/std-client": major | ||
--- | ||
|
||
- Moved `createActionSystem` from `std-client` to `recs` package and updated it to better support v2 sync stack. | ||
|
||
If you want to use `createActionSystem` alongside `syncToRecs`, you'll need to pass in arguments like so: | ||
|
||
```ts | ||
import { syncToRecs } from "@latticexyz/store-sync/recs"; | ||
import { createActionSystem } from "@latticexyz/recs/deprecated"; | ||
import { from, mergeMap } from "rxjs"; | ||
|
||
const { blockLogsStorage$, waitForTransaction } = syncToRecs({ | ||
world, | ||
... | ||
}); | ||
|
||
const txReduced$ = blockLogsStorage$.pipe( | ||
mergeMap(({ operations }) => from(operations.map((op) => op.log?.transactionHash).filter(isDefined))) | ||
); | ||
|
||
const actionSystem = createActionSystem(world, txReduced$, waitForTransaction); | ||
``` | ||
|
||
- Fixed a bug in `waitForComponentValueIn` that caused the promise to not resolve if the component value was already set when the function was called. | ||
|
||
- Fixed a bug in `createActionSystem` that caused optimistic updates to be incorrectly propagated to requirement checks. To fix the bug, you must now pass in the full component object to the action's `updates` instead of just the component name. | ||
|
||
```diff | ||
actions.add({ | ||
updates: () => [ | ||
{ | ||
- component: "Resource", | ||
+ component: Resource, | ||
... | ||
} | ||
], | ||
... | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
packages/recs/tests/Entity.spec.ts → packages/recs/src/Entity.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
packages/recs/tests/Performance.spec.ts → packages/recs/src/Performance.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
packages/recs/tests/System.spec.ts → packages/recs/src/System.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
packages/recs/tests/World.spec.ts → packages/recs/src/World.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export enum ActionState { | ||
Requested = "Requested", | ||
Executing = "Executing", | ||
WaitingForTxEvents = "WaitingForTxEvents", | ||
Complete = "Complete", | ||
Failed = "Failed", | ||
Cancelled = "Cancelled", | ||
TxReduced = "TxReduced", | ||
} |
Oops, something went wrong.