     return { (progressCallback  : AsyncProgressCallback?,
               stateCallback     : AsyncChangeStateCallback?,
               doneCallbackOption: AsyncTypes<Value, Error>.DidFinishAsyncCallback?) -> AsyncHandler in
-        
+
         var loading = true
-        
+
         let wrappedDoneCallback = { (result: AsyncResult<Value, Error>) -> () in
-            
+
             loading = false
-            
+
             finishCallback?(result: result)
             doneCallbackOption?(result: result)
         }
-        
+
         let cancel = loader(
             progressCallback: progressCallback,
             stateCallback   : stateCallback   ,
             finishCallback  : wrappedDoneCallback)
-        
+
         if loading {
-            
+
             startBlock?()
             return cancel
         }
-        
+
         return jStubHandlerAsyncBlock
     }
 }

}

func neverFinishAsync() -> AsyncTypes<AnyObject, NSError>.Async {
    
    return { (progressCallback: AsyncProgressCallback?,
              stateCallback   : AsyncChangeStateCallback?,
              doneCallback    : AsyncTypes<AnyObject, NSError>.DidFinishAsyncCallback?) -> AsyncHandler in
        
        var wasCanceled = false
        
        return { (task: AsyncHandlerTask) -> () in
            
            if wasCanceled {
                return
            }
            
            wasCanceled = (task == .Cancel
                || task == .UnSubscribe)
            
            processHandlerTast(task, stateCallback: stateCallback, doneCallback: doneCallback)
        }
    }

}

public func async<Value, Error: ErrorType>(error error: Error) -> AsyncTypes<Value, Error>.Async {

    return { (progressCallback: AsyncProgressCallback?,
              stateCallback   : AsyncChangeStateCallback?,
              doneCallback    : AsyncTypes<Value, Error>.DidFinishAsyncCallback?) -> AsyncHandler in

        doneCallback?(result: .Failure(error))
        return jStubHandlerAsyncBlock
    }
}

public func async<Value, Error: ErrorType>(task task: AsyncHandlerTask) -> AsyncTypes<Value, Error>.Async {

    return { (progressCallback: AsyncProgressCallback?,
              stateCallback   : AsyncChangeStateCallback?,
              doneCallback    : AsyncTypes<Value, Error>.DidFinishAsyncCallback?) -> AsyncHandler in

        processHandlerTast(task, stateCallback: stateCallback, doneCallback: doneCallback)
        return jStubHandlerAsyncBlock
    }
