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

Add events that support AbortSignal #28

Closed
fregante opened this issue Nov 14, 2024 · 0 comments · Fixed by #29
Closed

Add events that support AbortSignal #28

fregante opened this issue Nov 14, 2024 · 0 comments · Fixed by #29
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@fregante
Copy link
Owner

listen(chrome.storage.onChanged, changes => {console.log}, {signal})

would replace

function listener(changes) {
	console.log(changes);
}
if (!signal.aborted) {
	chrome.storage.onChanged.addListener(changes);
	signal.addEventListener('abort', () => {
		chrome.storage.onChanged.removeListener(changes);
	})
}

Most of the logic is already in https://github.com/fregante/webext-events/blob/main/source/one-event.ts, which can then use this listen function internally and pass its own signal

@fregante fregante added enhancement New feature or request help wanted Extra attention is needed labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant