This commit is contained in:
Kevin Jahns 2015-07-21 17:25:07 +02:00
parent ee983ceff6
commit dd5e2adc87
2 changed files with 29 additions and 29 deletions

View File

@ -172,7 +172,7 @@ var Struct = {
left.right = op.id
yield* this.setOperation(left)
} 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
if (op.right != null) {

View File

@ -1,41 +1,41 @@
/* @flow */
function Y (opts) {
var def = Promise.defer();
new YConfig(opts, function(yconfig){ //eslint-disable-line
yconfig.db.whenUserIdSet(function(){
def.resolve(yconfig);
});
});
return def.promise;
var def = Promise.defer()
new YConfig(opts, function (yconfig) { // eslint-disable-line
yconfig.db.whenUserIdSet(function () {
def.resolve(yconfig)
})
})
return def.promise
}
class YConfig { //eslint-disable-line no-unused-vars
class YConfig { // eslint-disable-line no-unused-vars
constructor (opts, callback) {
this.db = new Y[opts.db.name](this, opts.db);
this.connector = new Y[opts.connector.name](this, opts.connector);
var yconfig = this;
this.db.requestTransaction(function*(){
this.db = new Y[opts.db.name](this, opts.db)
this.connector = new Y[opts.connector.name](this, opts.connector)
var yconfig = this
this.db.requestTransaction(function *() {
// create initial Map type
var model = {
id: ["_", 0],
struct: "Map",
type: "Map",
id: ['_', 0],
struct: 'Map',
type: 'Map',
map: {}
};
yield* this.addOperation(model);
var root = yield* this.createType(model);
this.store.y.root = root;
callback(yconfig);
});
}
yield* this.addOperation(model)
var root = yield* this.createType(model)
this.store.y.root = root
callback(yconfig)
})
}
destroy () {
this.connector.disconnect();
this.db.removeDatabase();
this.connector = null;
this.db = null;
this.transact = function(){
throw new Error("Remember?, you destroyed this type ;)");
};
this.connector.disconnect()
this.db.removeDatabase()
this.connector = null
this.db = null
this.transact = function () {
throw new Error('Remember?, you destroyed this type ;)')
}
}
}