-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dev-tools): use new sync stack (#1284)
- Loading branch information
Showing
64 changed files
with
775 additions
and
509 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,16 @@ | ||
--- | ||
"@latticexyz/common": minor | ||
--- | ||
|
||
`createContract` now has an `onWrite` callback so you can observe writes. This is useful for wiring up the transanction log in MUD dev tools. | ||
|
||
```ts | ||
import { createContract, ContractWrite } from "@latticexyz/common"; | ||
import { Subject } from "rxjs"; | ||
|
||
const write$ = new Subject<ContractWrite>(); | ||
creactContract({ | ||
... | ||
onWrite: (write) => write$.next(write), | ||
}); | ||
``` |
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,33 @@ | ||
--- | ||
"@latticexyz/dev-tools": major | ||
"create-mud": major | ||
--- | ||
|
||
MUD dev tools is updated to latest sync stack. You must now pass in all of its data requirements rather than relying on magic globals. | ||
|
||
```diff | ||
import { mount as mountDevTools } from "@latticexyz/dev-tools"; | ||
|
||
- mountDevTools(); | ||
+ mountDevTools({ | ||
+ config, | ||
+ publicClient, | ||
+ walletClient, | ||
+ latestBlock$, | ||
+ blockStorageOperations$, | ||
+ worldAddress, | ||
+ worldAbi, | ||
+ write$, | ||
+ // if you're using recs | ||
+ recsWorld, | ||
+ }); | ||
``` | ||
|
||
It's also advised to wrap dev tools so that it is only mounted during development mode. Here's how you do this with Vite: | ||
|
||
```ts | ||
// https://vitejs.dev/guide/env-and-mode.html | ||
if (import.meta.env.DEV) { | ||
mountDevTools({ ... }); | ||
} | ||
``` |
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,22 @@ | ||
--- | ||
"@latticexyz/react": minor | ||
--- | ||
|
||
Adds a `usePromise` hook that returns a [native `PromiseSettledResult` object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled). | ||
|
||
```tsx | ||
const promise = fetch(url); | ||
const result = usePromise(promise); | ||
|
||
if (result.status === "idle" || result.status === "pending") { | ||
return <>fetching</>; | ||
} | ||
|
||
if (result.status === "rejected") { | ||
return <>error fetching: {String(result.reason)}</>; | ||
} | ||
|
||
if (result.status === "fulfilled") { | ||
return <>fetch status: {result.value.status}</>; | ||
} | ||
``` |
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.