update
This commit is contained in:
parent
ee983ceff6
commit
dd5e2adc87
@ -172,7 +172,7 @@ var Struct = {
|
|||||||
left.right = op.id
|
left.right = op.id
|
||||||
yield* this.setOperation(left)
|
yield* this.setOperation(left)
|
||||||
} else {
|
} else {
|
||||||
op.right = op.parentSub ? (parent.map[op.parentSub] || null) : parent.start
|
op.right = op.parentSub ? parent.map[op.parentSub] || null : parent.start
|
||||||
}
|
}
|
||||||
// reconnect right
|
// reconnect right
|
||||||
if (op.right != null) {
|
if (op.right != null) {
|
||||||
|
56
src/y.js
56
src/y.js
@ -1,41 +1,41 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
function Y (opts) {
|
function Y (opts) {
|
||||||
var def = Promise.defer();
|
var def = Promise.defer()
|
||||||
new YConfig(opts, function(yconfig){ //eslint-disable-line
|
new YConfig(opts, function (yconfig) { // eslint-disable-line
|
||||||
yconfig.db.whenUserIdSet(function(){
|
yconfig.db.whenUserIdSet(function () {
|
||||||
def.resolve(yconfig);
|
def.resolve(yconfig)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
return def.promise;
|
return def.promise
|
||||||
}
|
}
|
||||||
|
|
||||||
class YConfig { //eslint-disable-line no-unused-vars
|
class YConfig { // eslint-disable-line no-unused-vars
|
||||||
constructor (opts, callback) {
|
constructor (opts, callback) {
|
||||||
this.db = new Y[opts.db.name](this, opts.db);
|
this.db = new Y[opts.db.name](this, opts.db)
|
||||||
this.connector = new Y[opts.connector.name](this, opts.connector);
|
this.connector = new Y[opts.connector.name](this, opts.connector)
|
||||||
var yconfig = this;
|
var yconfig = this
|
||||||
this.db.requestTransaction(function*(){
|
this.db.requestTransaction(function *() {
|
||||||
// create initial Map type
|
// create initial Map type
|
||||||
var model = {
|
var model = {
|
||||||
id: ["_", 0],
|
id: ['_', 0],
|
||||||
struct: "Map",
|
struct: 'Map',
|
||||||
type: "Map",
|
type: 'Map',
|
||||||
map: {}
|
map: {}
|
||||||
};
|
}
|
||||||
yield* this.addOperation(model);
|
yield* this.addOperation(model)
|
||||||
var root = yield* this.createType(model);
|
var root = yield* this.createType(model)
|
||||||
this.store.y.root = root;
|
this.store.y.root = root
|
||||||
callback(yconfig);
|
callback(yconfig)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
destroy () {
|
destroy () {
|
||||||
this.connector.disconnect();
|
this.connector.disconnect()
|
||||||
this.db.removeDatabase();
|
this.db.removeDatabase()
|
||||||
this.connector = null;
|
this.connector = null
|
||||||
this.db = null;
|
this.db = null
|
||||||
this.transact = function(){
|
this.transact = function () {
|
||||||
throw new Error("Remember?, you destroyed this type ;)");
|
throw new Error('Remember?, you destroyed this type ;)')
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user