             @outline = outline
 
             outline.onDidEndChanges () =>
-                @syncMaster.update(@, @outline.serialize())
-
-            amplify.subscribe 'data-updated', (source, data) =>
-                if source isnt this
-                    if data isnt @outline.serialize()
-                        outline.reloadSerialization(data)
-
+                @syncMaster.update(this, @outline.serialize())
+
+        onDataUpdated: (source, data) =>
+            if super(source, data)
+                @outline.reloadSerialization(@data)
 
     panel = new DockPanel()
     panel.id = 'main'

    class SyncMaster
        constructor: () ->
            @data = '\n'
        update: (source, data) ->
            @data = data
            amplify.publish 'data-updated', source, data

    syncMaster = new SyncMaster()

    class SyncView
        constructor: (syncMaster) ->
            @syncMaster = syncMaster
            @data = syncMaster.data

            amplify.subscribe 'data-updated', (source, data) =>
                @onUpdate(source, data)

        onDataUpdated: (source, data) ->
            if this isnt source and @data isnt data
                @data = data
                return true
            else
                return false

    class DocView extends SyncView
        constructor: (syncMaster, doc) ->
            super(syncMaster)
            @doc = doc
            @doc.setValue(@data)

            @doc.on 'change', () =>
                @data = @doc.getValue()
                @syncMaster.update(this, @data)

        onDataUpdated: (source, data) =>
            if super(source, data)
                @doc.setValue(@data)


    class OutlineView extends SyncView
