   icon: 'code'
   constructor: ->
     @sources = {}
+    @pending = []
     @runtime = null
 
     @inPorts = new noflo.InPorts


  doAsync: (name, callback) ->
    unless @runtime
      return callback new Error 'No runtime available'
    @runtime.sendComponent 'getsource',
      name: name


    @unsubscribe @runtime if @runtime
    runtime.on 'component', @handleMessage
    @runtime = runtime
    while @pending.length
      task = @pending.shift()
      @doAsync task.name, task.callback

  unsubscribe: (runtime) ->
    @sources = {}
