Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace watchWithFilter with pausableWatch #183

Closed

Conversation

gxr404
Copy link
Contributor

@gxr404 gxr404 commented Jun 27, 2024

Description

Infinite loop unexpectedly fixed by await storageInterface.getItem(key) in the previous PR

This approach is unreasonable. Relevant discussion

A better approach would be to pause the watch when the localstroage listen is triggered

View the commit history, the current code for useWebExtensionStorage is based on reference useStorageAsync

useStorageAsync here also did not use pausableWatch because browser mechanism is different from extension

// Event not triggered
window.addEventListener('storage', e=>{console.log(e)})
localStorage.setItem('test', 111)

// Event triggered
chrome.storage.onChanged.addListener(function() {console.log('trigger')})
chrome.storage.local.set({'test': 123})

Linked Issues

Why does extension need to customize useStorageAsync

Why use pausableWatch to replace watchWithFilter

@gxr404 gxr404 closed this Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant