Changeset - 9c5e62615a63
[Not reviewed]
default
0 1 0
Drew Perttula - 8 years ago 2017-06-10 09:14:01
drewp@bigasterisk.com
don't let handlers pile up (workaround)
Ignore-this: c99eb0cce187fe7a49ba163431503680
1 file changed with 16 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light9/web/graph.coffee
Show inline comments
 
@@ -75,7 +75,11 @@ class AutoDependencies
 
      throw new Error("missing label")
 

	
 
    h = new Handler(func, label)
 
    @handlerStack[@handlerStack.length - 1].innerHandlers.push(h)
 
    tailChildren = @handlerStack[@handlerStack.length - 1].innerHandlers
 
    matchingLabel = _.filter(tailChildren, ((c) -> c.label == label)).length
 
    # ohno, something depends on some handlers getting run twice :(
 
    if matchingLabel < 2
 
      tailChildren.push(h)
 
    console.time("handler #{label}")
 
    @_rerunHandler(h, null)
 
    console.timeEnd("handler #{label}")
 
@@ -93,10 +97,20 @@ class AutoDependencies
 
      #log('done. got: ', handler.patterns)
 
      @handlerStack.pop()
 
    # handler might have no watches, in which case we could forget about it
 

	
 
  _logHandlerTree: ->
 
    log('handler tree:')
 
    prn = (h, depth) ->
 
      indent = ''
 
      for i in [0...depth]
 
        indent += '  '
 
      log(indent + h.label)
 
      for c in h.innerHandlers
 
        prn(c, depth + 1)
 
    prn(@handlers, 0)
 
    
 
  graphChanged: (patch) ->
 
    # SyncedGraph is telling us this patch just got applied to the graph.
 

	
 
    rerunInners = (cur) =>
 
      toRun = cur.innerHandlers.slice()
 
      for child in toRun
 
@@ -188,7 +202,6 @@ class window.SyncedGraph
 
        if not q.graph?
 
          throw new Error("corrupt patch: #{q}")
 

	
 
    log('graph: patch', patch)
 
    @_applyPatch(patch)
 
    @_client.sendPatch(patch) if @_client
 

	
0 comments (0 inline, 0 general)