MessageChannel

Lesson 8 · ~8 minutes · mixed retrieval

Pick the pipe

The skill is not naming APIs in order. It is choosing a pipe — or rejecting one — under mixed prompts, then tearing a minted extra end down without killing the worker.

Pocket the playbook, then answer from memory. Same JS world calls a function (a React callback prop). A window handle still takes targetOrigin. A name plus many same-origin listeners is BroadcastChannel. A dedicated worker’s first stream is the implicit port. A SharedWorker’s first stream is the connect port. Mint a pair to hand a private end into another context — two iframes, or a worker talking to someone other than its creator. When that extra conversation is done, close() the handles you hold. terminate() is not teardown for one stream. (Choose, HTML §9.4.1.2, §9.4.5)

Check

A React parent wants a child in the same tree to report a click. What do you use?

Many same-origin tabs should hear “user logged in”. What do you use?

A dedicated worker and its creator need one two-way stream. What do you use?

A tab connects to a SharedWorker and needs one stream with it. What do you use?

Two iframes should chat. Parent should not be a party. What do you do?

The extra worker conversation is done. The worker should keep running. What do you do?

Primary source

Re-read the playbook on choose and HTML Living Standard §9.4.1.2 (a port is a capability you hand off). Teardown is still §9.4.5.

Ask the teacher

If two of these still collapse into each other — especially implicit vs extra vs connect port — ask. This unit was the retrieval drill for the mission’s choose-or-reject and teardown criteria. Pocket cards: entangled ports, port API, transfer, choose.