Giter Site home page Giter Site logo

Comments (5)

fregante avatar fregante commented on August 22, 2024

Did you have any specific requirements that led you to use a persistent port for this channel or was it because the docs seem to suggest there's only chrome.runtime.connect?

The regular sendMessage works in both devtools.html and devtoolsPanel.html:

Screen Shot 9

Screen Shot 8

I'll likely be implementing this part with the the regular sendMessage API, at least for the beginning.

from webext-messenger.

twschiller avatar twschiller commented on August 22, 2024

Did you have any specific requirements that led you to use a persistent port for this channel or was it because the docs seem to

Originally I did it because I was copypasta'ing docs.

When using normal messaging, can the background page initiate messages to the devtools? (What would the tab/frame be for the target?) In the "actor" model the devtools would need to send a message to the background page on initialization. At that point, it's like the port creation, but without the benefits of having a port

What are the benefits of having a port? 1) Lower latency? 2) Getting an event when the port connection is closed?

Maybe we start with regular message, and then move everything to ports (including content script) where it's supported?

from webext-messenger.

fregante avatar fregante commented on August 22, 2024

When using normal messaging, can the background page initiate messages to the devtools?

I think not, but as pointed out in #3 maybe this is never needed.

What are the benefits of having a port? 1) Lower latency? 2) Getting an event when the port connection is closed?

I think that's the idea.

Maybe we start with regular message, and then move everything to ports (including content script) where it's supported?

Yes, CS also supports ports. What concerns me though is that ports have a major inconvenience:

  • the message handler can't respond just by returning, it has to send a message back

This means:

  • the sender can't just await runtime.sendMessage but has to listen to messages and connect them to the original message sent
  • errors have to be serialized and deserialized manually (or at least handled manually)

For this reason I think I should find out whether the latency is actually lower enough to justify the complexity.

from webext-messenger.

twschiller avatar twschiller commented on August 22, 2024

What concerns me though is that ports have a major inconvenience:

In my mind, a potential benefit this library is to put an abstraction around that, so clients can get the benefits of the port, while still being able to do it with a standard async call

from webext-messenger.

fregante avatar fregante commented on August 22, 2024

As later discovered, the port only appears to have lower latency because the connection has to happen beforehand. Regular messages have the same latency after the first message to a context.

See pixiebrix/pixiebrix-extension#1546 (comment)

from webext-messenger.

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.