Upgrade telepath

This commit is contained in:
Kevin Sawicki
2013-07-10 09:15:24 -07:00
parent 5ce0cf65c4
commit b1ca43ac0f
8 changed files with 10 additions and 11 deletions

View File

@@ -75,7 +75,7 @@ class EditSession
@displayBuffer.on 'grammar-changed', => @handleGrammarChange()
@state.observe ({key, newValue}) =>
@state.on 'changed', ({key, newValue}) =>
switch key
when 'scrollTop'
@trigger 'scroll-top-changed', newValue

View File

@@ -18,7 +18,7 @@ class PaneAxis extends View
@state = telepath.Document.create(deserializer: @className(), children: [])
@addChild(child) for child in args
@state.get('children').observe ({index, inserted, removed, site}) =>
@state.get('children').on 'changed', ({index, inserted, removed, site}) =>
return if site is @state.site.id
for childState in removed
@removeChild(@children(":eq(#{index})").view(), updateState: false)

View File

@@ -24,7 +24,7 @@ class PaneContainer extends View
else
@state = telepath.Document.create(deserializer: 'PaneContainer')
@state.observe ({key, newValue, site}) =>
@state.on 'changed', ({key, newValue, site}) =>
return if site is @state.site.id
if key is 'root'
@setRoot(deserialize(newValue), updateState: false)

View File

@@ -35,14 +35,14 @@ class Pane extends View
deserializer: 'Pane'
items: @items.map (item) -> item.getState?() ? item.serialize()
@state.get('items').observe ({index, removed, inserted, site}) =>
@state.get('items').on 'changed', ({index, removed, inserted, site}) =>
return if site is @state.site.id
for itemState in removed
@removeItemAtIndex(index, updateState: false)
for itemState, i in inserted
@addItem(deserialize(itemState), index + i, updateState: false)
@state.observe ({key, newValue, site}) =>
@state.on 'changed', ({key, newValue, site}) =>
return if site is @state.site.id
@showItemForUri(newValue) if key is 'activeItemUri'

View File

@@ -16,7 +16,7 @@ class GuestSession
console.log 'connection opened'
connection.once 'data', (data) =>
console.log 'received document'
doc = telepath.Document.deserialize(telepath.createSite(@getId()), data)
doc = telepath.Document.deserialize(data, site: telepath.createSite(@getId()))
atom.windowState = doc.get('windowState')
@participants = doc.get('participants')
connectDocument(doc, connection)

View File

@@ -22,11 +22,10 @@ class HostSession
@participants.push
id: @getId()
email: git.getConfigValue('user.email')
@participants.observe =>
@participants.on 'changed', =>
@trigger 'participants-changed', @participants.toObject()
@peer.on 'connection', (connection) =>
console.log connection
connection.on 'open', =>
console.log 'sending document'
connection.send(@doc.serialize())

View File

@@ -13,7 +13,7 @@ module.exports =
event.id = nextOutputEventId++
console.log 'sending event', event.id, event
connection.send(event)
doc.outputEvents.on('changed', outputListener)
doc.on('output', outputListener)
queuedEvents = []
nextInputEventId = 1
@@ -40,7 +40,7 @@ module.exports =
queuedEvents.push(event)
connection.on 'close', ->
doc.outputEvents.removeListener('changed', outputListener)
doc.off('changed', outputListener)
connection.on 'error', (error) ->
console.error 'connection error', error.stack ? error