feat(web): bidirectional message channel between page and background worker - #708
Draft
ened wants to merge 3 commits into
Draft
feat(web): bidirectional message channel between page and background worker#708ened wants to merge 3 commits into
ened wants to merge 3 commits into
Conversation
…worker Adds free-form two-way messaging between the app and the background worker, complementing request/response task execution: - WorkerProtocol: new 'message' (page -> worker) and 'workerMessage' (worker -> page) wire types - WorkmanagerExecution: messageHandler + sendToPage hooks on the Flutter-free dispatcher side - WorkmanagerWebWorker runtime: routes messages and wires sendToPage for both the dedicated Web Worker (postMessage) and the Service Worker (clients.postMessage) - WorkmanagerWeb: sendMessageToWorker() + workerMessages stream, including the in-page fallback path The web example demonstrates the channel with a live worker chat and a simulated price-watch use case (watch/stop/check messages, live ticks, and background task checks). Rebuilt web/background.dart.js.
… fewer buttons The web demo had five action buttons plus four chips stacked with the chat and the event log. Rework it around two tabs: - Worker chat: conversation + message input + three action chips - Task log: single 'Run check now' action + event list The periodic price-check task is now registered automatically on startup so the demo works with zero setup; cancel moved to the app bar menu. Status is a single line instead of a paragraph.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds free-form two-way messaging between the app and the background worker on web, complementing request/response task execution.
WorkerProtocol: newmessage(page -> worker) andworkerMessage(worker -> page) wire typesWorkmanagerExecution:messageHandler+sendToPagehooks on the Flutter-free dispatcher sideWorkmanagerWebWorkerruntime: routes messages and wiressendToPagefor both the dedicated Web Worker (postMessage) and the Service Worker (clients.postMessage)WorkmanagerWeb:sendMessageToWorker()+workerMessagesstream, including the in-page fallback pathNo IsolateNameServer equivalent exists on web — this is the postMessage/IndexedDB communication model.
Verification
dart analyzeclean (package + example)flutter build webbuilds;web/background.dart.jsrebuilt