add storage events change handling

This commit is contained in:
buzz-lightsnack-2007 2024-03-29 20:25:42 +08:00
parent 84c09c0b47
commit 94b01ea25b

View file

@ -382,3 +382,14 @@ export function init(data) {
});
}
}
/*
Run a script when the browser storage has been changed.
@param {object} reaction the function to run
*/
export async function observe(reaction) {
chrome.storage.onChanged.addListener((changes, namespace) => {
reaction(changes, namespace);
});
}