Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

egghead.io

Establish Callback and Closure patterns Around Async Browser Behaviors

via egghead.io

Overview

JavaScript is full of inconsistent APIs. Wrapping those APIs in functions allows you to have full control over how to configure them and make them more reusable.
This becomes even more beneficial when dealing with the async nature of JavaScript. You'll learn how a broadcaster is a function that wraps another function (which we call listeners) and modifies the behavior. We will build up this pattern in a way that allows you to compose broadcasters together making your code more reusable.
You're in Section 02 of Composing Closures and Callbacks in JavaScript

Syllabus

  • Create a Function to Configure setTimeout
  • Return a Function to Cancel an Async Behavior
  • Wrap addEventListener in a Function for More Control
  • Create a Utility Function to Control setInterval
  • Combine Multiple Async Behaviors with a Merge Function
  • Use Lodash Curry When Functions Return Functions
  • Match Function Requirements with Lodash Partial and Flip
  • Create a Buffer to Pair Values Together with Zip
  • Pass an Array to a Callback with a forOf Function
  • Pass a Done Symbol when an Async Function is Done

Taught by

John Lindquist

Reviews

4.8 rating at egghead.io based on 61 ratings

Start your review of Establish Callback and Closure patterns Around Async Browser Behaviors

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.