on-zero 0.1.16 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/readme.md +7 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "on-zero",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "A typed layer over @rocicorp/zero with queries, mutations, and permissions",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@take-out/helpers": "0.1.
|
|
67
|
+
"@take-out/helpers": "0.1.19",
|
|
68
68
|
"@sinclair/typebox-codegen": "^0.11.1",
|
|
69
69
|
"chokidar": "^4.0.3",
|
|
70
70
|
"citty": "^0.1.6",
|
package/readme.md
CHANGED
|
@@ -540,24 +540,25 @@ run a query once without subscribing. works on both client and server:
|
|
|
540
540
|
import { run } from 'on-zero'
|
|
541
541
|
import { userById } from '~/data/queries/user'
|
|
542
542
|
|
|
543
|
-
// with params
|
|
543
|
+
// with params - defaults to cache only on client
|
|
544
544
|
const user = await run(userById, { id: userId })
|
|
545
545
|
|
|
546
|
+
// fetch from server (waits for sync)
|
|
547
|
+
const user = await run(userById, { id: userId }, 'complete')
|
|
548
|
+
|
|
546
549
|
// without params
|
|
547
550
|
const allUsers = await run(allUsers)
|
|
548
551
|
|
|
549
|
-
//
|
|
550
|
-
const
|
|
552
|
+
// without params, fetch from server
|
|
553
|
+
const allUsers = await run(allUsers, 'complete')
|
|
551
554
|
```
|
|
552
555
|
|
|
553
556
|
on-zero run is smart:
|
|
554
557
|
|
|
555
|
-
- on client, uses client `zero.run()`
|
|
558
|
+
- on client, uses client `zero.run()`
|
|
556
559
|
- on server, uses server `zero.run()`
|
|
557
560
|
- in a mutation, uses `tx.run()`
|
|
558
561
|
|
|
559
|
-
this gives you a nice api.
|
|
560
|
-
|
|
561
562
|
**preloading data (client only):**
|
|
562
563
|
|
|
563
564
|
preload query results into cache without subscribing:
|