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 !
conceptsterminology
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 !
Best Answer
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 maytrigger
the change of state or as the result of thattrigger
execute the associatedcallback
.handler
is a reference to an object or class that is associated with a behavior. Ahandler
is different from acallback
because it's an object that represents a state.Using jQuery AJAX as an example.
function()
is acallback
.$.ajax(...)
is ahandler
.done()
is atrigger
.The
handler
has an eventdone
that whentriggered
calls thecallback
to perform$(this).addClass("done");
.