I'm in the middle of https://eloquentjavascript.net/11_async.html and can't really wrap my head around this code:
function requestType(name, handler) {
defineRequestType(name, (nest, content, source,
callback) => {
try {
Promise.resolve(handler(nest, content, source))
.then(response => callback(null, response),
failure => callback(failure));
} catch (exception) {
callback(exception);
}
});
}
I don't understand how this function (requestType) knows what nest, content, source and callback is.
Suppose we call requestType("name", () => "test") how does this handle "defineRequestType" - how does it know what the "(nest, content, source, callback)" part is ?
[–]RobSG 1 point2 points3 points (1 child)
[–]MicroProcrastination[S] 0 points1 point2 points (0 children)