pixiebrix-extension icon indicating copy to clipboard operation
pixiebrix-extension copied to clipboard

Update Messenger pattern to clarify the messenger usage

Open fregante opened this issue 3 years ago • 0 comments

What does this PR do?

Something I forgot to do when I implemented this:

  • Pre-binds sidebar messenger methods to the sidebar instead of having to specify { tabId: "this", page: "/sidebar.html" } every time

And a proposal around the usage of Messenger methods:

  • Always use sidebar.method() instead of method() to clarify that the method is related to the sidebar

I applied the proposal only to the sidebar, but once accepted we can change the background one too since it's also pre-bound:

- proxyService()
+ background.proxyService()

This does make it a little more verbose and explicit to call these methods, but maybe it helps readability.

The content script’s messenger isn't affected by this much considering that every call is followed by the target already:

cancelForm(thisTab)

fregante avatar Aug 30 '22 11:08 fregante