Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

It's current to see the terms callback, trigger and handler in some API documentations. It is just synonymous or each term correspond to a specific concept?

I used to think that this terms are just synonymous, but I must be wrong ...

Thanks !

share|improve this question

1 Answer 1

up vote 8 down vote accepted

These are general terms in programming. Often can mean different things but generally speaking...

callback is a reference to a function or block of code that is executed by a third party.

trigger is a behavior in response to stimuli, and an event may trigger the change of state or as the result of that trigger execute the associated callback.

handler is a reference to an object or class that is associated with a behavior. A handler is different from a callback because it's an object that represents a state.

Using jQuery AJAX as an example.

   url: "test.html",
   context: document.body
}).done(function() {
  • The function() is a callback.
  • The object passed to $.ajax(...) is a handler.
  • The event done() is a trigger.

The handler has an event done that when triggered calls the callback to perform $(this).addClass("done");.

share|improve this answer
is a handler executed by a third party too ? By a trigger by example? is a handler just a complex callback ? – nouney Jul 23 '13 at 19:31
handler is like a callback except that it can do multiple things, where as a callback is singular. A handler might handle success, timeout or errors as an example. – ThinkingMedia Jul 23 '13 at 19:35
Well thanks :). – nouney Jul 23 '13 at 19:45
@tdammers In your opinion, what's the difference between a handler and a callback then ? – nouney Jul 24 '13 at 8:13
@nouney: it's a conceptual difference more than a technical one. 'Callback' refers to the technical mechanism of passing function A to function B, and then having B call A as part of its processing. 'Handler' highlights the intent that some sort of event is handled; this is often done with callbacks, but there are other mechanisms that one can use for this. – tdammers Jul 25 '13 at 8:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.