From 76082e3d3033b09b02b6db64de6e36942593c753 Mon Sep 17 00:00:00 2001 From: pacexy Date: Mon, 13 Jan 2025 15:03:33 +0800 Subject: [PATCH] docs: fix mismatched variable names (#19184) --- docs/guide/api-environment-runtimes.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/guide/api-environment-runtimes.md b/docs/guide/api-environment-runtimes.md index 37a5f68badc4c6..851175ce3bf6d5 100644 --- a/docs/guide/api-environment-runtimes.md +++ b/docs/guide/api-environment-runtimes.md @@ -304,7 +304,7 @@ function createWorkerEnvironment(name, config, context) { const handlerToWorkerListener = new WeakMap() const workerHotChannel = { - send: (data) => w.postMessage(data), + send: (data) => worker.postMessage(data), on: (event, handler) => { if (event === 'connection') return @@ -312,20 +312,20 @@ function createWorkerEnvironment(name, config, context) { if (value.type === 'custom' && value.event === event) { const client = { send(payload) { - w.postMessage(payload) + worker.postMessage(payload) }, } handler(value.data, client) } } handlerToWorkerListener.set(handler, listener) - w.on('message', listener) + worker.on('message', listener) }, off: (event, handler) => { if (event === 'connection') return const listener = handlerToWorkerListener.get(handler) if (listener) { - w.off('message', listener) + worker.off('message', listener) handlerToWorkerListener.delete(handler) } },