@interncom/diplomatic 0.0.1 → 0.0.2
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 +15 -9
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Secure sync layer for web apps.
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```tsx
|
|
8
|
-
import {
|
|
8
|
+
import { StateManager, useStateWatcher, localStorageStore, DiplomaticClient } from '@interncom/diplomatic'
|
|
9
9
|
|
|
10
10
|
const appState = { count: 0 };
|
|
11
11
|
const stateMgr = new StateManager(async (op) => {
|
|
@@ -14,21 +14,27 @@ const stateMgr = new StateManager(async (op) => {
|
|
|
14
14
|
}
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
+
const client = new DiplomaticClient({
|
|
18
|
+
seed: "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
|
|
19
|
+
hostURL: "https://diplomatic-cloudflare-host.root-a00.workers.dev",
|
|
20
|
+
stateManager: stateMgr,
|
|
21
|
+
store: localStorageStore,
|
|
22
|
+
});
|
|
23
|
+
|
|
17
24
|
export default function App() {
|
|
18
|
-
const [client] = useClient({
|
|
19
|
-
seed: "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
|
|
20
|
-
hostURL: "https://diplomatic-cloudflare-host.root-a00.workers.dev",
|
|
21
|
-
stateManager: stateMgr,
|
|
22
|
-
})
|
|
23
25
|
const count = useStateWatcher(stateMgr, "count", () => appState.count)
|
|
24
26
|
const inc = () => client.upsert("count", count + 1)
|
|
25
27
|
|
|
26
28
|
return (
|
|
27
|
-
|
|
29
|
+
<div style={{ width: "100vw", textAlign: "center" }}>
|
|
28
30
|
<h1>COUNT</h1>
|
|
29
31
|
<h2>{count}</h2>
|
|
30
|
-
<button
|
|
31
|
-
|
|
32
|
+
<button onClick={inc}>+1</button>
|
|
33
|
+
</div>
|
|
32
34
|
)
|
|
33
35
|
}
|
|
34
36
|
```
|
|
37
|
+
|
|
38
|
+
## Development
|
|
39
|
+
|
|
40
|
+
To deploy npm package: `npm publish --public`.
|
package/dist/index.js
CHANGED