GoogleChromeLabs / GoogleChromeLabs/comlink

Expose main to worker, same remote-object-style

Open
#522 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
12.8k
Forks
435
PR merge metrics
No merged PRs in 30d

Description

Could not find this in examples.

[`worker-rpc`](https://www.npmjs.com/package/worker-rpc) allows the worker to request values from main in a similar manner, (`await remote.func()`).

I understand you can pass callbacks using `Comlink.proxy`, but in some cases (an apparent) direct duplex communication indicates the intent better than passing the ball back-and-forth where the main should has first call a function, then the worker must memoize the callback etc.

Is this kind of duplex communication also possible with Comlink? What would be an example?

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.