This is a draft of a decent architecture I can now think of:
popup
wait until currently active tab's status is complete
send a special message to check if the script is responsive at all. If not, this must be one of: 404, pdf, etc. or a major content script error
get the tab-dependent information from chrome.storage.local key TAB_DEPENDENT_XXX. It may have a flag hasLoaded set to false.
listen to changes to chrome.storage.local key TAB_DEPENDENT_XXX and update components on change.
content script
set a listener to answer the popup that the content script is responsive
set a listener for this tab becoming active to set tab-dependent information for popup reads at chrome.storage.local key TAB_DEPENDENT_XXX. If the content script annotations etc. have not loaded yet, set some flag such as hasLoaded to false.
when the tab data has changed (e.g. annotations have been loaded), update values at TAB_DEPENDENT_XXX
This flow has been replaced using webext-redux.
It is possible that some ideas here can be reused, but for now the flow is effective and these improvements don't really apply now.
This is a draft of a decent architecture I can now think of:
popup
wait until currently active tab's status is
complete
send a special message to check if the script is responsive at all. If not, this must be one of: 404, pdf, etc. or a major content script error
get the tab-dependent information from chrome.storage.local key
TAB_DEPENDENT_XXX
. It may have a flaghasLoaded
set to false.listen to changes to chrome.storage.local key
TAB_DEPENDENT_XXX
and update components on change.content script
TAB_DEPENDENT_XXX
. If the content script annotations etc. have not loaded yet, set some flag such ashasLoaded
to false.TAB_DEPENDENT_XXX