From 059f72ffe10c587a7036c2f45e7d72917138b271 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Tue, 30 Aug 2016 18:10:19 +0200 Subject: [PATCH] fix init problems with v12, update examples to be synchronous --- dist | 2 +- src/y.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dist b/dist index 4726c71d..15615024 160000 --- a/dist +++ b/dist @@ -1 +1 @@ -Subproject commit 4726c71dd0e95db9200b92c4434729954539edd9 +Subproject commit 15615024f38b93198775bd71f26c5096ffc95a0a diff --git a/src/y.js b/src/y.js index 8bce847a..ab93871d 100644 --- a/src/y.js +++ b/src/y.js @@ -140,6 +140,9 @@ class YConfig { for (var propertyname in opts.share) { var typeConstructor = opts.share[propertyname].split('(') var typeName = typeConstructor.splice(0, 1) + var type = Y[typeName] + var typedef = type.typeDefinition + var id = ['_', typedef.struct + '_' + typeName + '_' + propertyname + '_' + typeConstructor] var args = [] if (typeConstructor.length === 1) { try { @@ -147,11 +150,13 @@ class YConfig { } catch (e) { throw new Error('Was not able to parse type definition! (share.' + propertyname + ')') } + if (type.typeDefinition.parseArguments == null) { + throw new Error(typeName + ' does not expect arguments!') + } else { + args = typedef.parseArguments(args[0])[1] + } } - var type = Y[typeName] - var typedef = type.typeDefinition - var id = ['_', typedef.struct + '_' + typeName + '_' + propertyname + '_' + typeConstructor] - share[propertyname] = this.store.createType(type.apply(typedef, args), id) + share[propertyname] = yield* this.store.initType.call(this, id, args) } this.store.whenTransactionsFinished() .then(callback)