Here, what you have is a curried function written using the relatively newer arrow function syntax. In short what a curried function does is, it returns another function when called.
The name of curried function is createHandleError, which accepts a single parameter named serviceName. The parameter (serviceName) has a default value set to it as (serviceName = '')
. An empty string ''
is the default value of service name.
So, calling createHandleError will return an another function which will accept two parameters namely operation and result (these also have default value allocated to it) and is to show generic parameter list (Just a type). And then it calls handleError function and passes all three parameters to it ie (serviceName, operation, result)
.
You can call createHandleError like this:
let intermediateCreateHandleErrorFunction = createHandleError("nameOfTheService");
intermediateCreateHandleErrorFunction(someOperation, someResult);
Also, you can call createHandleError like this:
createHandleError("nameOfTheService")(someOperation, someResult);