How can I define callback function as parameter

I want to create a global HTTP request function/extension with Alamofire. It's like:

function Request(requestPath:String, requestParams:Any, onComplate:Void) {
 // stuff here, when async request complate i want to call onComplate function
 // like C# method.Invoke() or func.Invoke()


  • Thanks for reply but finally solution

    class HttpRequest<Request, Response>
        private var serviceBase:String = "";
        func request(path:String, model: Request, success: @escaping((_ response: [Response]?) -> ()), failure: @escaping ((_ error:String) -> ()) {
             // code here..