Comparing version 0.4.4 to 0.4.5
@@ -64,3 +64,3 @@ var Link = require('./Link') | ||
link.on('error', function() { | ||
link.on('editError', function() { | ||
link.send('requestInit') | ||
@@ -81,3 +81,3 @@ }.bind(this)) | ||
link.on('error', function() { | ||
link.on('editError', function() { | ||
this.history.latest(function(er, latest) { | ||
@@ -106,3 +106,3 @@ if(er) return link.emit('error', er) // XXX: send this error to the document | ||
this.history.latest(function(er, latest) { | ||
if(er) return link.emit('error', er) | ||
if(er) return link.emit('error', er) // XXX: send this error to the document | ||
var content = (this.ottype.serialize)? this.ottype.serialize(this.content) : this.content | ||
@@ -152,2 +152,3 @@ link.send('init', {content: content, initialEdit: latest.pack()}) | ||
this.links.forEach(function(link) { link.reset() }) | ||
this.content = content | ||
@@ -195,3 +196,3 @@ this.history.reset() | ||
this.history.remembers(edit.id, function(er, remembers) { | ||
if(er) return fromLink.emit('error',er) | ||
if(er) return fromLink.emit('error',er) // XXX: Send this error to the document | ||
@@ -207,3 +208,3 @@ if (remembers) { | ||
if (!remembersParent) { | ||
return fromLink.emit('error', new Error('Edit "'+edit.id+'" has unknown parent "'+edit.parent+'"')) | ||
return fromLink.emit('editError', new Error('Edit "'+edit.id+'" has unknown parent "'+edit.parent+'"')) | ||
} | ||
@@ -213,3 +214,3 @@ | ||
if(er) { | ||
fromLink.emit('error', er) | ||
fromLink.emit('editError', er) | ||
return cb() | ||
@@ -221,3 +222,3 @@ } | ||
}catch(er) { | ||
fromLink.emit('error', er) | ||
fromLink.emit('editError', er) | ||
return cb() | ||
@@ -224,0 +225,0 @@ } |
@@ -8,3 +8,3 @@ // Stores revisions that are synced with the server | ||
History.prototype.reset = function() { | ||
if('function' == typeof this.document.adapter.reset) this.document.adapter.reset() | ||
} | ||
@@ -11,0 +11,0 @@ |
@@ -18,10 +18,8 @@ var Duplex = require('stream').Duplex | ||
}.bind(this)) | ||
this.on('editError', function(er) { | ||
console.warn('EditError in link', 'undefined'!=typeof window? er : er.stack || er) | ||
}) | ||
// Never touch the edits in a queue of a non-master link! | ||
// (Imagine with no master link you were to transform a pending edit against an incoming one, but the pending edit has | ||
// already been added to the document's history -- so a new local edit would have the same parent (the incoming one) as the pending edit before it. | ||
// this leads to unexpected results..) | ||
this.queue = [] | ||
this.callbacks = {} | ||
this.reset() | ||
} | ||
@@ -32,2 +30,8 @@ Link.prototype = Object.create(Duplex.prototype, { constructor: { value: Link }}) | ||
Link.prototype.reset = function() { | ||
this.queue = [] | ||
this.sentEdit = null | ||
this.callbacks = {} | ||
} | ||
/** | ||
@@ -34,0 +38,0 @@ * Pipeline an event |
{ | ||
"name": "gulf", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"description": "Sync anything!", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33191
721