YoVDO

Composing Closures and Callbacks in JavaScript

Offered By: egghead.io

Tags

Javascript Courses RxJS Courses Closures Courses

Course Description

Overview

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 what 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 broadcasting values to another function that is listening 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.

Syllabus


    Taught by

    John Lindquist

    Related Courses

    Work with augmented reality (AR) and the web
    Curtin University via edX
    Learn Intermediate Swift
    Codecademy
    Learn Swift: Closures
    Codecademy
    Advanced JavaScript 3: Objects, Collections, Functions
    Scrimba via Coursera
    Introduction to Javascript and Ajax: Building Web Apps
    Johns Hopkins University via Coursera