LearnNewsExamplesServices
Frontmatter
id8126
titleManager.mjs: Refactor `onWorkerMessage` to remove redundancy
stateClosed
labels
airefactoring
assigneestobiu
createdAtDec 16, 2025, 7:37 PM
updatedAtDec 16, 2025, 7:48 PM
githubUrlhttps://github.com/neomjs/neo/issues/8126
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtDec 16, 2025, 7:48 PM

Manager.mjs: Refactor onWorkerMessage to remove redundancy

Closed v11.17.0 airefactoring
tobiu
tobiu commented on Dec 16, 2025, 7:37 PM

The onWorkerMessage method in src/worker/Manager.mjs has accumulated redundant logic for handling message replies, specifically the promise registration and sendMessage sequence. This has been exacerbated by the recent addition of updateVdom handling and the zero-delta optimization.

Goal: Refactor onWorkerMessage to eliminate code duplication by extracting the common reply/promise logic into a reusable helper method.

Plan:

  1. Identify the common pattern:
    • Check for deltas.
    • If empty -> Immediate reply.
    • If present -> Register promise -> Fire event -> Send reply on promise resolution.
  2. Create a helper method handleDomUpdate({ data, eventName }).
    • data: The message payload.
    • eventName: The event to fire (e.g., 'updateVdom', 'automount').
  3. Update onWorkerMessage to use this helper for both action === 'updateVdom' and the action === 'reply' (VDOM) path.

This will reduce file size and improve maintainability.

tobiu added the refactoring label on Dec 16, 2025, 7:37 PM
tobiu assigned to @tobiu on Dec 16, 2025, 7:37 PM
tobiu added the ai label on Dec 16, 2025, 7:48 PM
tobiu referenced in commit 0137fd8 - "Manager.mjs: Refactor onWorkerMessage to remove redundancy #8126" on Dec 16, 2025, 7:48 PM
tobiu closed this issue on Dec 16, 2025, 7:48 PM