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

Setting key to undefined doesn't actually change it #29

Open
Kitenite opened this issue Dec 9, 2023 · 0 comments
Open

Setting key to undefined doesn't actually change it #29

Kitenite opened this issue Dec 9, 2023 · 0 comments

Comments

@Kitenite
Copy link

Kitenite commented Dec 9, 2023

Google search terms

extend-chrome setting undefined

Describe the bug

When setting a key in useBucket to undefined (or null), the value doesn't get changed. It resolves to the previous value instead.
Removing the key works.

How do we reproduce?

This is my bucket

export interface StateValue {
	sidePanelTabId: number | undefined
}
export const stateBucket = getBucket<StateValue>('EXTENSION_STATE')

When I set the value to undefined (in async context), the value does not change in the valueStream


stateBucket.valueStream.subscribe({sidePanelTabId} => {
		console.log('stateBucket changed', obj) //  First run: undefined, 2nd run: 1, 3rd run: 1, 4th run: undefined
})

stateBucket.set({sidePanelTabId: 1})
stateBucket.set({sidePanelTabId: undefined})
stateBucket.remove("sidePanelTabId")

Expected behavior

The third run should print undefined instead of 1.

Actual behavior

The third run prints the last value: 1

Screenshots

Please complete the following information:

  • Library Version: "^1.5.0"
  • Operating System: MacOS Sonoma 14.1.2 (23B92)
  • Browser: Chrome
  • Node Version: 18

Additional context

Run in the background script

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

No branches or pull requests

1 participant