persistence updates + make Persistence.init async
This commit is contained in:
@@ -4,14 +4,14 @@ window.onload = function () {
|
||||
window.yXmlType.bindToDom(document.body)
|
||||
}
|
||||
|
||||
let persistence = null // new Y.IndexedDBPersistence()
|
||||
const persistence = new Y.IndexedDB()
|
||||
|
||||
// initialize a shared object. This function call returns a promise!
|
||||
let y = new Y({
|
||||
let y = new Y('htmleditor', {
|
||||
connector: {
|
||||
name: 'websockets-client',
|
||||
url: 'http://127.0.0.1:1234',
|
||||
room: 'x'
|
||||
room: 'html-editor'
|
||||
// maxBufferLength: 100
|
||||
}
|
||||
}, persistence)
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
/* global Y, CodeMirror */
|
||||
|
||||
// initialize a shared object. This function call returns a promise!
|
||||
Y({
|
||||
db: {
|
||||
name: 'memory'
|
||||
},
|
||||
const persistence = new Y.IndexedDB()
|
||||
const connector = {
|
||||
connector: {
|
||||
name: 'websockets-client',
|
||||
room: 'codemirror-example'
|
||||
},
|
||||
sourceDir: '/bower_components',
|
||||
share: {
|
||||
codemirror: 'Text' // y.share.codemirror is of type Y.Text
|
||||
}
|
||||
}).then(function (y) {
|
||||
window.yCodeMirror = y
|
||||
}
|
||||
// initialize a shared object. This function call returns a promise!
|
||||
const y = Y('codemirror-example', connector, persistence)
|
||||
window.yCodeMirror = y
|
||||
|
||||
var editor = CodeMirror(document.querySelector('#codeMirrorContainer'), {
|
||||
mode: 'javascript',
|
||||
lineNumbers: true
|
||||
})
|
||||
y.share.codemirror.bindCodeMirror(editor)
|
||||
var editor = CodeMirror(document.querySelector('#codeMirrorContainer'), {
|
||||
mode: 'javascript',
|
||||
lineNumbers: true
|
||||
})
|
||||
y.share.codemirror.bindCodeMirror(editor)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
import Y from '../src/Y.js'
|
||||
import yWebsocketsClient from '../../y-websockets-client/src/y-websockets-client.js'
|
||||
import IndexedDBPersistence from '../../y-indexeddb/src/y-indexeddb.js'
|
||||
import extendYIndexedDBPersistence from '../../y-indexeddb/src/y-indexeddb.js'
|
||||
|
||||
Y.extend(yWebsocketsClient)
|
||||
Y.IndexedDBPersistence = IndexedDBPersistence
|
||||
extendYIndexedDBPersistence(Y)
|
||||
|
||||
export default Y
|
||||
|
||||
Reference in New Issue
Block a user