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 !
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.
Sign up to join this communityIt'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 !
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.
$.ajax({
url: "test.html",
context: document.body
}).done(function() {
$(this).addClass("done");
});
function()
is a callback
.$.ajax(...)
is a handler
.done()
is a trigger
.The handler
has an event done
that when triggered
calls the callback
to perform $(this).addClass("done");
.
handler
executed by a third party too ? By a trigger
by example? is a handler
just a complex callback
?
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.
Jul 23, 2013 at 19:35
handler
and a callback
then ?
Handler, an asynchronous callback subroutine. Handler implements interceptor design pattern. Which is used to handle incoming or outgoing messages and manipulate its values.
A callback is a piece of executable code that is passed as an argument to other code, which is expected to call back (execute) the argument at some convenient time. The invocation may be immediate as in a synchronous callback, or it might happen at later time as in an asynchronous callback.
Callbacks implements in different ways Closure , lambda expressions and so on...
Triggers are rules, it executes on events.