Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: delete store-cache package #1343

Merged
merged 5 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/metal-wombats-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@latticexyz/store-cache": major
---

Removes `store-cache` package. Please see the [changelog](https://mud.dev/changelog) for how to migrate your app to the new `store-sync` package. Or create a new project from an up-to-date template with `pnpm create mud@next your-app-name`.

If you need reactivity, we recommend using `recs` package and `syncToRecs`. We'll be adding reactivity to `syncToSqlite` in a future release.
5 changes: 5 additions & 0 deletions .changeset/spicy-bees-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/react": major
---

Removes `useRow` and `useRows` hooks, previously powered by `store-cache`, which is now deprecated. Please use `recs` and the corresponding `useEntityQuery` and `useComponentValue` hooks. We'll have more hooks soon for SQL.js sync backends.
28 changes: 0 additions & 28 deletions packages/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,6 @@

React hooks (and more) for building MUD clients.

## Hooks for `store-cache`

### useRows

Returns an array of all rows matching the provided filter. Re-renders if the filter changes or if table entries matching the provided filter change.

```typescript
// get a list of all entries in the database
const allRows = useRows(storeCache);
// -> [ { namespace: "", table: "Position", key: { key: "0x01" }, value: { x: 1, y: 2 } }, ... ]

// get a list of all entries in the Position table
const allPositionRows = useRows(storeCache, { table: "Position" });

// get a list of all entries in the position table with key greater than `0x0A`
const filteredRows = useRows(storeCache, { table: "Position", key: { gt: { key: "0x0A" } } });
```

### useRow

Returns a single row with the provided key in the provided table. Re-renders if the filter changes or if the value of this row changes.

```typescript
// get the Position value of key `0x01`
const position = useRow(storeCache, { table: "Position", key: { key: "0x01" } });
// -> { namespace: "", table: "Position", key: { key: "0x01" }, value: { x: 1, y: 2 } }
```

## Hooks for `recs`

### useComponentValue
Expand Down
1 change: 0 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"dependencies": {
"@latticexyz/recs": "workspace:*",
"@latticexyz/store": "workspace:*",
"@latticexyz/store-cache": "workspace:*",
"fast-deep-equal": "^3.1.3",
"mobx": "^6.7.0",
"react": "^18.2.0",
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ export * from "./useDeprecatedComputedValue";
export * from "./useEntityQuery";
export * from "./useObservableValue";
export * from "./usePromise";
export * from "./store-cache";
2 changes: 0 additions & 2 deletions packages/react/src/store-cache/index.ts

This file was deleted.

197 changes: 0 additions & 197 deletions packages/react/src/store-cache/useRow.test.ts

This file was deleted.

23 changes: 0 additions & 23 deletions packages/react/src/store-cache/useRow.ts

This file was deleted.

Loading