A callback function is one which is passed as an argument to another function and is invoked after the completion of the parent function.
In other words 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.
Eg.
In this example what we want to do is to call our callback function test when the function a is finished with its execution. What we do is that we pass the address of our callback function test to the function a . After we are done with the code of function a we call the callback function by calling callback(), internally this function will call our required callback function test as we have passed it as an argument.
Give your suggestion or feedback in the comments section.
In other words 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.
Eg.
In this example what we want to do is to call our callback function test when the function a is finished with its execution. What we do is that we pass the address of our callback function test to the function a . After we are done with the code of function a we call the callback function by calling callback(), internally this function will call our required callback function test as we have passed it as an argument.
Give your suggestion or feedback in the comments section.
No comments:
Post a Comment