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

Taught in

References

Certification courses