You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not sure it is needed (yet), but we have been putting more stuff in background.js and it might be worth it to structure it a bit more and possibly split it up according to functionality.
Just making this issue so we can discuss it and so I don't forget.
The text was updated successfully, but these errors were encountered:
I'd argue that this is probably needed sooner than later. Especially with notifications, web requests, and other stuff becoming more complicated, this is something we should tackle sooner than later - don't want to leave it too long and have to refactor some truly massive file later. I have some ideas for this that I can write up in a bit.
I think we should revise the format we use for message passing to the background page, and then we can use a separate file for each type of message that comes in. e.g. tb-request is separated from tb-global is separated from tb-notification. We could even tackle some of #44 at the same time.
// background/actions/one.jsactionHandlers.one=(options,sender)=>{// A simple synchronous message handlerreturn'some value';// The return value is sent as the message response }
// background/actions/two.jsasyncfunctionsomeStuff(){// ...}actionHandlers.two=async(options,sender)=>{// A simple asynchronous message handlerconstresponse=awaitsomeStuff();returnresponse;// The return value is still sent as the message response}
This would change the pattern for sending messages from sendMessage({action, ...otherOptions}) to sendMessage([action, otherOptions]) which is good because then we can use the action key as an option rather than it needing to be special (tb-global would benefit from this). This also means that each file can maintain its own utility functions without getting too messy.
I am not sure it is needed (yet), but we have been putting more stuff in background.js and it might be worth it to structure it a bit more and possibly split it up according to functionality.
Just making this issue so we can discuss it and so I don't forget.
The text was updated successfully, but these errors were encountered: