Design patterns·Who calls whom, and when
you passed a function in and something else decided when to call it, possibly twice, possibly never.
Callback
Also calledcallback function, continuation, handler function
Handing a function to another component to be invoked later, the smallest possible form of inversion of control. It is a one-off observer, a one-function strategy and the primitive under every event API. Its costs are the ones every asynchronous codebase learns: no guarantee about how many times or on which thread it runs, and error handling that does not follow the call stack.