Composing Closures and Callbacks in JavaScript
Learn how to effectively use callbacks in JavaScript to enhance your problem-solving skills. This course guides you through creating reusable functions and solving common challenges like Callback Hell and debouncing. Take your coding skills to the next level with this advanced beginner course.
As a developer, you’ll often make use of APIs that have you pass in a callback function. For example, adding event listeners or using various other DOM or Node APIs.
What’s less common is writing your own code that makes use of callbacks. Many developers know
a callback is, but not the why or how of implementing them in their projects.
A callback is a function that you pass to another function, so that the function that you pass it to controls the invocation of that function.
To help keep things straight, John Lindquist calls the innermost callback the Listener, and the function it gets passed into the Broadcaster.
Think of it as one function
values to another function that is
for them.
These Broadcaster-Listener callback relationships can be composed to solve problems in the realm of timing, buffering, and caching.
This pattern of composing callbacks is the foundation of RxJS and other libraries that handle complex async scenarios.
In this course, John Lindquist guides you from a blank JavaScript file all the way through creating a library of reusable functions not unlike those found in RxJS. The difference is you’ll be writing from scratch.
You’ll learn techniques for solving Callback Hell with composition, implementing debouncing, and building a word game among several other examples.
Using callbacks in code is a major pattern in JavaScript, and learning to work with them effectively will take your problem-solving skills to the next level.
advanced beginner
advanced beginner