Factor out methods for index manipulation
This commit is contained in:
parent
e55e5155b7
commit
76678f7b27
|
@ -210,7 +210,7 @@ Dataspace.prototype.applyPatch = function (ac, delta) {
|
||||||
delta.forEach((count, a) => {
|
delta.forEach((count, a) => {
|
||||||
if (a !== void 0) {
|
if (a !== void 0) {
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
this.index.adjustAssertion(a, count);
|
this.adjustIndex(a, count);
|
||||||
} else {
|
} else {
|
||||||
removals.push([count, a]);
|
removals.push([count, a]);
|
||||||
}
|
}
|
||||||
|
@ -218,10 +218,18 @@ Dataspace.prototype.applyPatch = function (ac, delta) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
removals.forEach(([count, a]) => {
|
removals.forEach(([count, a]) => {
|
||||||
this.index.adjustAssertion(a, count);
|
this.adjustIndex(a, count);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Dataspace.prototype.sendMessage = function (m) {
|
||||||
|
this.index.sendMessage(m);
|
||||||
|
};
|
||||||
|
|
||||||
|
Dataspace.prototype.adjustIndex = function (a, count) {
|
||||||
|
return this.index.adjustAssertion(a, count);
|
||||||
|
};
|
||||||
|
|
||||||
Dataspace.prototype.subscribe = function (handler) {
|
Dataspace.prototype.subscribe = function (handler) {
|
||||||
this.index.addHandler(handler, handler.callback);
|
this.index.addHandler(handler, handler.callback);
|
||||||
};
|
};
|
||||||
|
@ -383,7 +391,7 @@ function Message(body) {
|
||||||
|
|
||||||
Message.prototype.perform = function (ds, ac) {
|
Message.prototype.perform = function (ds, ac) {
|
||||||
if (this.body !== void 0) {
|
if (this.body !== void 0) {
|
||||||
ds.index.sendMessage(Immutable.fromJS(this.body));
|
ds.sendMessage(Immutable.fromJS(this.body));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue