Comments (6)
As long as you wait on the iframe’s onload
, you are fine (you can build your own ready()
or something to make it more semantically meaningful). Here’s a glitch example.
I can’t really bake that mechanism into Comlink as the mechanism differs for Workers, iFrames and what not.
Does that help?
from comlink.
@surma that does help, but the idea was more of having a generic mechanism that works for all kinds of targets.
Is it not possible that
- when
proxy
is called, send aload-check
message to the target - when
expose
is called or whenload-check
message is received, send aloaded
message to the target
Cannot such a mechanism, implement this in a generic way ?
from comlink.
I don’t think there’s a generic and reliable way to make sure the channel is initialized — exactly because there’s no way to make sure the load-check
message doesn’t get lost itself. You have to rely on the underlying channel semantics to make sure it’s ready.
Imma close this for now, but feel free to re-open if you think you have a good way!
from comlink.
@surma In my case, a child iframe application is waiting to receive an API via getInstance()...the challenge I'm facing is that the react or angular child application in the child iframe has already finished rendering by the time the proxied instance is received. Hence, there is a large delay sending comlink.proxyValue(...) and the only way to guarantee that the proxied value exists prior is have a hook that mounts the iframe content after resolving ---> await api.Comunication.getInstance();
from comlink.
I can’t quite follow. Neither expose()
nor proxyValue()
send anything. The just hook up to a message channel.
The process is inherently async, there’s nothing I can do about that. If you need to wait for the other side to be “ready” in some form, then that needs to be build on top of Comlink.
Can you maybe give me an example I can test with?
from comlink.
I answered my own question. Thanks. Like you mentioned, it needs to be build on top of Comlink.
from comlink.
Related Issues (20)
- Web Worker Hangs if Imported File Contains Top-Level `Await` HOT 6
- Service worker example: stops working when SW is suspended HOT 9
- Set operation is not awaitable HOT 2
- Possible to communicate between web workers? HOT 1
- How to transfer result buffers HOT 2
- [feat] DeasyncEndpoint HOT 2
- Move from Karma to Playwright? HOT 1
- Do I need to use transfer inside a proxy? HOT 1
- Add support for async transferHandle serializer/deserializer HOT 2
- Significant performance optimizations possible in `requestResponseMessage` HOT 4
- Push notifications from web worker HOT 5
- Memory leak when terminating worker with ongoing call HOT 2
- Worker Pool for similar tasks HOT 2
- Sharing constructed objects within a remote context HOT 1
- How to implement comlink in Next.js 14 App Route HOT 2
- Feature request: Automatic proxy of arguments HOT 3
- Having issues when using comlink with react (storing in react state) HOT 3
- Exposed function deadlocks if called too early
- Returning a collection - transferHandlers to be called
- How to prevent auto `releaseProxy`?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from comlink.