README: update provider tutorial

This commit is contained in:
Kevin Jahns 2019-05-12 11:18:43 +02:00
parent 81a529d8dc
commit c80f446b5f
3 changed files with 8 additions and 6 deletions

View File

@ -83,8 +83,10 @@ import * as Y from 'yjs'
import { WebsocketProvider } from 'y-websocket'
import { TextareaBinding } from 'y-textarea'
const provider = new WebsocketProvider('http://localhost:1234')
const doc = provider.get('roomname')
const doc = Y.Doc()
const provider = new WebsocketProvider('http://localhost:1234', 'roomname')
// sync all document updates through the websocket connection
provider.sync('doc')
// Define a shared type on the document.
const ytext = doc.getText('my resume')
@ -433,7 +435,7 @@ doc1.getArray('myarray').insert(0, ['Hello doc2, you got this?'])
doc2.getArray('myarray').get(0) // => 'Hello doc2, you got this?'
```
Yjs internally maintains a [State Vector](#State-Vector) that denotes the next expected clock from each client. In a different interpretation it holds the number of structs created by each client. When two clients sync, you can either exchange the complete document structure or only the differences by sending the state vector to compute the differences.
Yjs internally maintains a [state vector](#State-Vector) that denotes the next expected clock from each client. In a different interpretation it holds the number of structs created by each client. When two clients sync, you can either exchange the complete document structure or only the differences by sending the state vector to compute the differences.
**Example: Sync two clients by exchanging the complete document structure**

View File

@ -285,7 +285,7 @@ export class AbstractItem extends AbstractStruct {
* @private
*/
copy (id, left, origin, right, rightOrigin, parent, parentSub) {
throw new Error('unimplemented')
throw error.methodUnimplemented()
}
/**
@ -393,7 +393,7 @@ export class AbstractItem extends AbstractStruct {
* @private
*/
splitAt (transaction, diff) {
throw new Error('unimplemented')
throw error.methodUnimplemented()
}
/**

View File

@ -101,7 +101,7 @@ export class AbstractType {
* @private
*/
_copy () {
throw new Error('unimplemented')
throw error.methodUnimplemented()
}
/**