Code Monkey home page Code Monkey logo

Comments (6)

surma avatar surma commented on September 26, 2024

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.

git-jiby-me avatar git-jiby-me commented on September 26, 2024

@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 a load-check message to the target
  • when expose is called or when load-check message is received, send a loaded message to the target

Cannot such a mechanism, implement this in a generic way ?

from comlink.

surma avatar surma commented on September 26, 2024

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.

adrianromanko avatar adrianromanko commented on September 26, 2024

@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.

surma avatar surma commented on September 26, 2024

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.

adrianromanko avatar adrianromanko commented on September 26, 2024

I answered my own question. Thanks. Like you mentioned, it needs to be build on top of Comlink.

from comlink.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.