WHAT’S IN THIS CHAPTER?
- Creating and testing code that uses callback functions
- Creating and testing callback functions
- Identifying and addressing problems that are commonly encountered when implementing the Callback Pattern
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
The wrox.com code downloads for this chapter are found at
A callback is a function provided as an argument to a second function, which the second function will execute at some time in the future. That future time may be before the second function has exited, in which case the callback is considered synchronous. Alternatively, the future time may be after the second function has exited, in which case the callback is considered asynchronous. While all the examples in this chapter will use synchronous callbacks, the techniques (and potential problems) are also applicable to asynchronous callbacks. Chapter 6 will introduce promises, which are used exclusively with asynchronous callbacks.
The sections that follow illustrate how to create reliable callback functions when interacting with ...