Permalink
Browse files

Merge pull request #106 from collin/offline

adds an acknowledge event to Doc class
  • Loading branch information...
2 parents 745ee1f + d7efbf0 commit 7223fb66883ced42b8b81e11d7e5d5f2751dd331 @wmertens wmertens committed Jun 11, 2012
Showing with 16 additions and 2 deletions.
  1. +2 −0 src/client/doc.coffee
  2. +11 −0 test/client.coffee
  3. +1 −1 webclient/share.js
  4. +2 −1 webclient/share.uncompressed.js
View
@@ -17,6 +17,7 @@ if WEB?
# Events:
# - remoteop (op)
# - changed (op)
+# - acknowledge (op)
# - error
# - open, closing, closed. 'closing' is not guaranteed to fire before closed.
class Doc
@@ -195,6 +196,7 @@ class Doc
@serverOps[@version] = oldInflightOp
@version++
+ @emit 'acknowledge', oldInflightOp
callback null, oldInflightOp for callback in @inflightCallbacks
# Send the next op.
View
@@ -263,6 +263,17 @@ genTests = (client) -> testCase
doc.submitOp sentOp, (error, v) ->
passPart()
+ 'doc fires acknowledge event when it recieves acknowledgement from server': (test) ->
+ passPart = makePassPart test, 1
+ @c.open @name, 'text', (error, doc) =>
+ test.fail error if error
+ sentOp = [{i:'asdf', p:0}]
+ doc.on 'acknowledge', (op) ->
+ test.deepEqual op, sentOp
+ passPart()
+
+ doc.submitOp sentOp
+
'doc does not receive ops after close called': (test) ->
@c.open @name, 'text', (error, doc) =>
doc.on 'change', (op) ->
Oops, something went wrong.

0 comments on commit 7223fb6

Please sign in to comment.