 Fiber = Npm.require 'fibers'
 
-checkNames = (publish, collectionNames, computation, result) ->
+getCollectionNames = (result) ->
   if result and _.isArray result
     resultNames = (cursor._getCollectionName() for cursor in result when _.isObject(cursor) and '_getCollectionName' of cursor)
   else if result and _.isObject(result) and '_getCollectionName' of result


    result = publishFunction.apply publish, args

    return unless checkNames publish, collectionNames, null, result

    # Specially handle if computation has been returned.
    if result instanceof Tracker.Computation

      handle = Tracker.autorun (computation) ->
        result = runFunc.call publish, computation

        collectionNames = getCollectionNames result
        allCollectionNames[computation._id] = collectionNames

        computation.onInvalidate ->
          delete allCollectionNames[computation._id]

        unless checkNames publish, allCollectionNames, "#{computation._id}", collectionNames
          computation.stop()
          return

