-
Notifications
You must be signed in to change notification settings - Fork 454
Feature/op metadata support #586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
56c4afb
1581dc6
71f36b1
f845c4f
06b290d
5939b98
6ba9af8
26c71ae
3bcbb05
2cb16ee
7954c44
fb28eed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -600,9 +600,7 @@ Doc.prototype._otApply = function(op, source) { | |
); | ||
} | ||
|
||
// NB: If we need to add another argument to this event, we should consider | ||
// the fact that the 'op' event has op.src as its 3rd argument | ||
this.emit('before op batch', op.op, source); | ||
this.emit('before op batch', op.op, source, op.src, {op: op}); | ||
|
||
// Iteratively apply multi-component remote operations and rollback ops | ||
// (source === false) for the default JSON0 OT type. It could use | ||
|
@@ -637,24 +635,24 @@ Doc.prototype._otApply = function(op, source) { | |
this._setData(this.type.apply(this.data, componentOp.op)); | ||
this.emit('op', componentOp.op, source, op.src); | ||
} | ||
this.emit('op batch', op.op, source); | ||
this.emit('op batch', op.op, source, op.src, {op: op}); | ||
// Pop whatever was submitted since we started applying this op | ||
this._popApplyStack(stackLength); | ||
return; | ||
} | ||
|
||
// The 'before op' event enables clients to pull any necessary data out of | ||
// the snapshot before it gets changed | ||
this.emit('before op', op.op, source, op.src); | ||
this.emit('before op', op.op, source, op.src, {op: op}); | ||
// Apply the operation to the local data, mutating it in place | ||
this._setData(this.type.apply(this.data, op.op)); | ||
// Emit an 'op' event once the local data includes the changes from the | ||
// op. For locally submitted ops, this will be synchronously with | ||
// submission and before the server or other clients have received the op. | ||
// For ops from other clients, this will be after the op has been | ||
// committed to the database and published | ||
this.emit('op', op.op, source, op.src); | ||
this.emit('op batch', op.op, source); | ||
this.emit('op', op.op, source, op.src, {op: op}); | ||
this.emit('op batch', op.op, source, op.src, {op: op}); | ||
return; | ||
} | ||
|
||
|
@@ -866,6 +864,12 @@ Doc.prototype.submitOp = function(component, options, callback) { | |
callback = options; | ||
options = null; | ||
} | ||
|
||
// If agent has metadata, append on client level so that both client and backend have access to it | ||
if(this.connection.agent && this.connection.agent.custom && typeof this.connection.agent.custom.metadata === "object") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand why we're doing this? The Also |
||
component.m = Object.assign({}, component.m, this.connection.agent.custom.metadata); | ||
} | ||
|
||
var op = {op: component}; | ||
var source = options && options.source; | ||
this._submit(op, source, callback); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,7 +171,8 @@ SubmitRequest.prototype.commit = function(callback) { | |
var op = request.op; | ||
op.c = request.collection; | ||
op.d = request.id; | ||
op.m = undefined; | ||
op.m = request.agent.custom.metadata ? request.op.m : undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed above, we shouldn't be using |
||
|
||
// Needed for agent to detect if it can ignore sending the op back to | ||
// the client that submitted it in subscriptions | ||
if (request.collection !== request.index) op.i = request.index; | ||
|
Uh oh!
There was an error while loading. Please reload this page.