tshaddix / webext-redux

A set of utilities for building Redux applications in Web Extensions.
MIT License
1.22k stars 179 forks source link

How to re-sync store from "content script" with background.js (service worker)? #295

Closed lukasfarina closed 10 months ago

lukasfarina commented 10 months ago

Hey friends, I have a chrome extension and I am suffering from IDLE after being inactive for 30 seconds. After that, when trying to perform a dispatch, my content_script does not respond, as it is no longer connected to the store.

vladnikolov86 commented 10 months ago

Do something like that chrome.runtime.sendMessage({ type: "Random Message", }); in an interval, like every 10 seconds. This will keep your extension and its state alive.

lukasfarina commented 10 months ago

Do something like that chrome.runtime.sendMessage({ type: "Random Message", }); in an interval, like every 10 seconds. This will keep your extension and its state alive.

I did, but it seems that this still didn't solve or increase the Tab cache much.

What I did to solve it was: When activating the serviceWorker (background.js), I send a manual message to the content script and reassemble the components and the store using new Store(); This resolved it here, thank you very much for your help!