Skip to content

Commit

Permalink
Add applyMany to SharedBuffer
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Sobo <[email protected]>
  • Loading branch information
Antonio Scandurra committed Jun 6, 2017
1 parent 8ba1352 commit 39f26f4
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/shared-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,21 @@ class SharedBuffer {
}

apply (op) {
const opToSend = this.replica.applyLocal(op)
const opId = opIdToString(opToSend.opId)
this.appliedOperationIds.add(opId)
return this.applyMany([op])
}

applyMany (operations) {
const opsToSend = []
for (let i = operations.length - 1; i >= 0; i--) {
const op = operations[i]
const opToSend = this.replica.applyLocal(op)
const opId = opIdToString(opToSend.opId)
this.appliedOperationIds.add(opId)
opsToSend.push(opToSend)
}
return this.restGateway.post(
`/shared-buffers/${this.id}/operations`,
{operations: [opToSend]}
{operations: opsToSend}
)
}

Expand Down

0 comments on commit 39f26f4

Please sign in to comment.