Skip to content

docs: clarify bidirectional Comlink patterns#696

Open
KirtiRamchandani wants to merge 1 commit into
GoogleChromeLabs:mainfrom
KirtiRamchandani:docs/bidirectional-patterns
Open

docs: clarify bidirectional Comlink patterns#696
KirtiRamchandani wants to merge 1 commit into
GoogleChromeLabs:mainfrom
KirtiRamchandani:docs/bidirectional-patterns

Conversation

@KirtiRamchandani

Copy link
Copy Markdown

Problem

Root cause

  • wrap() talks to one value exposed by the other side, while expose() makes one local value available. Users can miss that callbacks, proxied objects, or additional endpoints are needed when both sides need to call each other.

Solution

  • Add a short README section describing supported bidirectional patterns:
    • pass callbacks or objects with Comlink.proxy()
    • use Comlink.createEndpoint() or a separate MessageChannel for another long-lived proxy
    • avoid assuming wrap() and expose() alone expose both local object graphs

Tests run

  • npx prettier@2.8.3 --check README.md
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explicitly mention in the document of Comlink's limitation on bidirectional communication between main thread and worker

1 participant