callback function
A function you hand to other code so that it can call it later, for example when a timer fires or an event happens.
In more detail
Callbacks let a library run your code at the right moment without knowing what it does. Event handlers and completion hooks are common kinds of callback.
Examples
An event loop keeps pending timer callbacks; cancelling one is cheap when you hold its node in a linked list.kafka-python calls on_partitions_assigned after a rebalance.onMutate, onError and onSettled are callbacks passed to a TanStack Query mutation.Related terms
- event loop — The central loop of an asynchronous program that waits for events, such as timers firing or data arriving, and runs the matching callbacks.
- ConsumerRebalanceListener — A kafka-python class you subclass to run your own code when a consumer gains or loses partitions during a rebalance.
- partitioner — The producer component that chooses which partition each record is sent to.
- event handler — A function that runs when something happens to an element, such as a click (onClick) or a key press (onKeyDown).
- controlled component — A component whose state, such as whether it is open or checked, is passed in by its parent, which also handles changes.
- delegate — A type that holds a reference to a method, so a method can be stored in a variable and called later.
- IOptionsMonitor<T> — The singleton options interface whose CurrentValue always reflects the latest configuration and whose OnChange callback fires on reload.
- mutation lifecycle callbacks — The functions TanStack Query calls at each stage of a mutation: onMutate before it is sent, onSuccess or onError after, and onSettled at the very end.
- async and await — Language keywords for writing code that waits for slow work, such as a network call, without blocking a thread.
- reset function — The function error.tsx receives that re-renders the failed segment to try again.
Taught in
- Agent SDKs And Human Approval — AI Engineering: LLM Apps, RAG & Agents
- Linked Lists: Nodes, Pointers And Sentinels — Algorithms & Data Structures for Working Engineers
- Green Tests, Red Production — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Where Is The Password Kept? — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Polymorphism & Slotted Composition: The asChild Pattern — Design Systems & Component Engineering
- Focus Management: Trapping, Restoration & Focus Rings — Design Systems & Component Engineering
- Storybook & Component Driven Development Workflows — Design Systems & Component Engineering
- The Options Pattern: Strongly Typed Configuration — Modern .NET Core, C# & Enterprise Microservices
- OAuth2 & OpenID Connect: Social Auth & PKCE Flows — Production Full-Stack Engineering
- Optimistic UI Architecture: Cache & Rollback Protocols — Production Full-Stack Engineering
- Structured Logging & Correlation IDs: Context Stitching — Production Full-Stack Engineering
- Consumer Groups And Partition Assignment — Apache Kafka & Event Streaming
- Rebalancing And Its Cost — Apache Kafka & Event Streaming
- Error Boundaries: Nested error.tsx & Reset Logic — Next.js 15 & Modern App Router Architecture
- Action State: useActionState & Optimistic Form UI — Next.js 15 & Modern App Router Architecture