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

feat(frontend): create Storage Setter store #3094

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AntonioVentilii-DFINITY
Copy link
Collaborator

@AntonioVentilii-DFINITY AntonioVentilii-DFINITY commented Oct 24, 2024

Motivation

For the token group store, we need a mix between the Storage store and the map provided by the Certified store. Meaning that we want saved in local storage some thing that is

{
  id1: data1,
  id2: data2,
  ...
}

In this PR we create a new type of Storage store that resembles the mapping provided by the Certified store.

@AntonioVentilii-DFINITY AntonioVentilii-DFINITY marked this pull request as ready for review October 24, 2024 09:25
@AntonioVentilii-DFINITY AntonioVentilii-DFINITY requested a review from a team as a code owner October 24, 2024 09:25
Copy link
Member

@peterpeterparker peterpeterparker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth writing a small test too?


return {
set: ({ key, value }) => {
setStorage({ key, value });
set(value);
},
update,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not leak "update" because a consumer can use it and the value does not get saved in the local storage.

Is there another way?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried without it and it is really not what i would do... basically it uses subscribe and not in a functional way... let me think a bit and come back on this


return newState;
}),
resetAll: reset,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my idea is that resetAll would reset the entire storage

I can rename it resetStorage?

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.

2 participants