@anfenn/zync 0.3.0 → 0.3.1
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/README.md +3 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,12 +29,14 @@ Simple, bullet-proof, offline-first sync middleware for Zustand.
|
|
|
29
29
|
- `updated_at`: Server assigned **_millisecond_** timestamp (db trigger or api layer). The client will never send this as the client clock is unlikely to be in sync with the server, so is never used for change detection. If it has a higher precision than millisecond, like PostgreSQL's microsecond timestampz, updates could be ignored.
|
|
30
30
|
- `deleted`: Boolean, used for soft deletes, to allow other clients to download deleted records to keep their local records in sync
|
|
31
31
|
|
|
32
|
-
## Quickstart
|
|
32
|
+
## Quickstart
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
35
|
npm install @anfenn/zync
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
*The example below uses server assigned id's, but you can just set the id when creating an object for client assigned id's.*
|
|
39
|
+
|
|
38
40
|
### Zustand store creation (store.ts):
|
|
39
41
|
|
|
40
42
|
```ts
|
|
@@ -244,10 +246,6 @@ async function firstLoad(lastId: any) {
|
|
|
244
246
|
}
|
|
245
247
|
```
|
|
246
248
|
|
|
247
|
-
## Client side assigned id
|
|
248
|
-
|
|
249
|
-
As simple as just setting the id field when creating a new record (and amend model types if using Typescript)
|
|
250
|
-
|
|
251
249
|
## Optional IndexedDB storage
|
|
252
250
|
|
|
253
251
|
Using async IndexedDB over sync localStorage gives the advantage of a responsive UI when reading/writing a very large store, as IndexedDB is running in it's own thread.
|