Loading video player…

Welcome to the Weather Station Dashboard

You’ll learn how JavaScript schedules code, how to stop it, and when to use workers. Your project is a weather-station dashboard, ported from Python. Each weather station, such as Ridge, sends samples to a panel, and an operator refreshes the panels.

Here’s a first taste. The dashboard asks a timer to update the Ridge panel with a delay of 0, then sums Ridge’s samples:

Language: JavaScript
setTimeout(() => console.log("Ridge panel updated"), 0);

const samples = [8, 12, 10];
const total = samples.reduce((sum, value) => sum + value, 0);
console.log("Ridge summary:", total);

The sum prints first anyway, and the panel waits:

Language: Program Output
Ridge summary: 30
Ridge panel updated

Would a longer sum keep the panel frozen? The next lesson finds out.

The operator presses refresh twice. Here, sleep() stands in for the station’s radio link: the first reply, 8, takes 300 milliseconds, and the newer one, 12, takes 50:

Language: JavaScript
import { setTimeout as sleep } from "node:timers/promises";

const dashboard = { ridge: "no reading yet" };

async function refreshRidge(delay, value) {
  const reading = await sleep(delay, value);
  dashboard.ridge = reading;
  console.log("Ridge panel:", dashboard.ridge);
}

await Promise.all([refreshRidge(300, 8), refreshRidge(50, 12)]);

The panel shows 12, then 8:

Language: Program Output
Ridge panel: 12
Ridge panel: 8

The older reading wins, with no error.

The real dashboard polls stations and stops polls when a shift ends. In the project, it sums samples in workers and prints both stations in order, with a total of 40:

Language: Program Output
{ id: 'Ridge', total: 30, count: 3 }
{ id: 'Harbor', total: 10, count: 2 }
total 40

By the end of this course, you’ll be able to:

  • See why a timer waits for running code, and in what order promise jobs, queueMicrotask() callbacks and timers run
  • Stop a poll with AbortController, and combine a deadline with an operator stop using AbortSignal.timeout() and AbortSignal.any()
  • Keep old readings out of the dashboard with a generation counter, and reserve a slot before you await
  • Move CPU work to a worker, and share a counter deliberately with SharedArrayBuffer and Atomics
  • Build the station summary dashboard, with one worker per station and every worker’s exit awaited

In Python, you only need to know asyncio’s event loop, tasks and cancellation, and threads and processes. In JavaScript, you only need to know promises, async functions with await, Promise.all(), timers, and modules.

You’ll need Node 26 or later installed, and no packages. The examples use Node 26 and Python 3.15.

The course mixes short videos with text lessons and exercises. Every video has a summary below it. A project video builds the dashboard, and a quiz and a summary close the course.

Next up: Why a Timer Waits for Your Code, where you see why a due timer can’t break into running code.

Download

Sample Code (.zip)

15.0 KB
Download

Course Slides (.pdf)

845.6 KB

00:00 Welcome to The JavaScript Event Loop, Concurrency, and Workers! You’ll learn how JavaScript schedules code, how to stop it, and when to use workers. Your project is a weather-station dashboard, ported from Python.

00:14 Each weather station, such as Ridge, sends samples to a panel, and an operator refreshes the panels. Here’s a first taste. The dashboard asks a timer to update the Ridge panel with no delay, then sums Ridge’s samples.

00:29 The sum prints first anyway, and the panel waits. Would a longer sum keep the panel frozen? The next lesson finds out.

00:39 The operator presses refresh twice. The first reply takes 300 milliseconds, and the newer one takes 50. The panel shows 12, then 8. The older reading wins, with no error.

00:56 The real dashboard polls stations and stops polls when a shift ends. In the project, it sums samples in workers and prints both stations in order, with a total of 40.

01:08 You’ll see why a timer waits, and when promises run. You’ll stop polls and keep old readings out. You’ll hand heavy work to workers. Then you’ll build the dashboard.

01:23 You need to know Python’s asyncio event loop, tasks, cancellation, threads and processes. In JavaScript, you need promises, async functions and timers. The examples use Node 26 and Python 3.15.

01:40 Short videos mix with text lessons and exercises, and every video has a summary below it. A quiz and a summary close the course. Next up: Why a Timer Waits for Your Code, where you see why a due timer can’t break into running code.

Become a Member to join the conversation.