     FiberUtils.synchronize guard, @_id, =>
       @invalidated = false
 
-      @_runInside @_func
+      @_runInside (computation) =>
+        while @_beforeRunCallbacks.length
+          callback = @_beforeRunCallbacks.shift()
+          Tracker.nonreactive =>
+            callback @
+
+        @_func.call null, @
+
+        while @_afterRunCallbacks.length
+          callback = @_afterRunCallbacks.shift()
+          Tracker.nonreactive =>
+            callback @
 
   _needsRecompute: ->
     @invalidated and not @stopped

    else
      @_onStopCallbacks.push f

  invalidate: ->
    # TODO: Why some tests freeze if we wrap this method into FiberUtils.synchronize?
    if not @invalidated


      delete Tracker._computations[@_id]

      while @_onStopCallbacks.length
        callback = @_onStopCallbacks.shift()
        Tracker.nonreactive =>
          callback @

  # Runs an arbitrary function inside the computation. This allows breaking many assumptions, so use it very carefully.
  _runInside: (func) ->
