Update README.md
This commit is contained in:
parent
fa09ebfd82
commit
68b4418956
@ -140,7 +140,8 @@ the API docs.
|
|||||||
### Example: Using and combining providers
|
### Example: Using and combining providers
|
||||||
|
|
||||||
The most common way to combine providers is probably to combine some network provider with the local indexeddb provider:
|
The most common way to combine providers is probably to combine some network provider with the local indexeddb provider:
|
||||||
```typescript
|
|
||||||
|
```js
|
||||||
import * as Y from 'yjs'
|
import * as Y from 'yjs'
|
||||||
import { WebrtcProvider } from 'y-webrtc'
|
import { WebrtcProvider } from 'y-webrtc'
|
||||||
import { IndexeddbPersistence } from 'y-indexeddb'
|
import { IndexeddbPersistence } from 'y-indexeddb'
|
||||||
@ -173,9 +174,10 @@ async function main() {
|
|||||||
console.log(sum)
|
console.log(sum)
|
||||||
}
|
}
|
||||||
main()
|
main()
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Example output:
|
Example output:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
32 # stored sum from indexeddb (with 1 already added to it)
|
32 # stored sum from indexeddb (with 1 already added to it)
|
||||||
new sum: 38 # delayed new sum fetched from network
|
new sum: 38 # delayed new sum fetched from network
|
||||||
|
Loading…
x
Reference in New Issue
Block a user