anchor.diff:    isConnected: -> @client?.connection.state is "connected"
   
     subscribe: (channel, callback) -> 
  -    @subscriptions.push channel
  +    subscription = new Sync.Pusher.Subscription(@client, channel, callback)
  +    @channels.push(channel)
  +    @subscriptions.push(subscription)
  +    subscription
  +
  +  unsubscribeAll: ->
  +    subscription.cancel() for subscription in @subscriptions
  +    @subscriptions = []
  +
  +
  +    
  +class Sync.Pusher.Subscription
  +  constructor: (@client, channel, callback) ->
  +    @pusherSub = channel
  +    
       channel = @client.subscribe(channel)
       channel.bind 'sync', callback
  -
  -
  -  unsubscribeAll: ->
  -    for subscription in @subscriptions
  -      @client.unsubscribe(subscription) if @client.channel(subscription)?
  -    @subscriptions = []
  +    
  +  cancel: ->
  +    @client.unsubscribe(@pusherSub) if @client.channel(@pusherSub)?
   
   
   class Sync.View
  
positive.code: 
  
    subscribe: ->
      @adapter.subscribe @channelUpdate, (data) =>
        if @refetch
          @refetchFromServer (html) => @update(html)
        else
          @update(data.html)
  
      @adapter.subscribe @channelDestroy, => @remove()
  
    
    update: (html) -> @view.beforeUpdate(html, {})
  
negative.code: 
  
    destroy: ->
      @subscriptionUpdate.cancel()
      @subscriptionDestroy.cancel()
      @$start.remove()
      @$end.remove()
      @$el?.remove()
  