       topic: topic
       payload: payload
     @outPorts.queued.send @changes.length
+    return @changes.length - 1
+
+  replaceChange: (offset, topic, payload) =>
+    @changes[offset] =
+      topic: topic
+      payload: payload
 
   addNode: (node) =>
     @registerChange 'addnode',

      graph: @graph.properties.id

  changeNode: (node) =>
    @registerChange 'changenode',
      id: node.id
      metadata: node.metadata
      graph: @graph.properties.id

  addEdge: (edge) =>
    @registerChange 'addedge',

    @outPorts.sent.send true
    @outPorts.sent.endGroup() if @graph
    @outPorts.queued.send @changes.length
    @changesStates = {}

  shutdown: ->
    do @unsubscribe
