         subscribe.apply(this, [sink])
 
 Bacon.dependsOn = (a,b) ->
+  # TODO: the allDeps thing could be pre-calculated and optimized for quick lookup
   if a == b
     return false
   deps = a.allDeps

            source.push e.value
            if source.sync
              UpdateBarrier.whenDone resultStream, ->
                for p in pats
                   if match(p)
                     val = -> p.f(sources[i.index].consume() for i in p.ixs ...)

  independent = (waiter) ->
    !_.any(waiters, ((other) -> Bacon.dependsOn(waiter.obs, other.obs)))
  whenDone = (obs, f) -> 
    waiters.push {obs, f}
  flush = ->
    if waiters.length
      #console.log "flushing, waiters", (_.map _.toString, (_.map ((x) -> x.obs), waiters))
      ok = _.filter independent, waiters
      firstIndex = _.indexWhere waiters, independent
      throw "no independent observable" if firstIndex < 0
      {f} = waiters.splice(firstIndex, 1)[0]
