Callback
Updated 2026-07-28
Summary
A callback function, or simply callback, is a reference to executable code in computer programming that is passed as an argument to other code; it is expected that this code will call back (execute) the callback function as part of its work. This execution can be immediate, as in synchronous callbacks, or it can occur at a later point in time, as in asynchronous callbacks. Programming languages support callbacks in different ways, often implementing them as subroutines, lambda expressions, blocks, or function pointers.
Definition
A callback function, or simply callback, is a reference to executable code in computer programming that is passed as an argument to other code; it is expected that this code will call back (execute) the callback function as part of its work. This execution can be immediate, as in synchronous callbacks, or it can occur at a later point in time, as in asynchronous callbacks. Programming languages support callbacks in different ways, often implementing them as subroutines, lambda expressions, blocks, or function pointers.
Introduction
How to use
A callback function, or simply callback, is a reference to executable code in computer programming that is passed as an argument to other code; it is expected that this code will call back (execute) the callback function as part of its work. This execution can be immediate, as in synchronous callbacks, or it can occur at a later point in time, as in asynchronous callbacks. Programming languages support callbacks in different ways, often implementing them as subroutines, lambda expressions, blocks, or function pointers.
Mechanism
A callback passes a function as an argument, and when a future event completes, the system calls it, implementing 'do it when the event arrives'. It hands control back to the framework (inversion of control), so the caller does not have to wait synchronously; it is the basis for asynchronous and plugin-based design.
Practice
In progress 0/5Practice this model in one real situation:
Cases
- A timer executes a callback when it expires; an event listener responds to a click.
Common pitfalls
- Applying synchronous thinking to asynchronous callbacks causes timing bugs; forgetting to unregister causes memory leaks.
Sources
Source support: Explicit
References currently contain only Wikipedia links; primary sources still need review.
- zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E5%9B%9E%E8%B0%83%E5%87%BD%E6%95%B0verified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS