   apply: -> this
   toString: -> "<error> #{@error}"
 
+idCounter = 0
+
 class Observable
   constructor: (desc) ->
+    @id = ++idCounter
     @assign = @onValue
     withDescription(desc, this)
   onValue: ->

        [x.obs]
      else
        []
    @apply = (obs) ->
      deps = _.cached (-> findDeps([context].concat(args)))
      obs.internalDeps = obs.internalDeps || deps
      obs.deps = deps
      obs.toString = -> _.toString(context) + "." + _.toString(method) + "(" + _.map(_.toString, args) + ")"
      obs.desc = -> { context, method, args }

      else
        subscribe.apply(this, [sink])

UpdateBarrier = (->
  tx = false
  waiters = []
  independent = (waiter) ->
    !_.any(waiters, ((other) -> waiter.obs.dependsOn(other.obs)))
  whenDone = (obs, f) -> 
    if tx
      if !_.any(waiters, (w) -> w.obs==obs)
