-
Notifications
You must be signed in to change notification settings - Fork 4
Separate adapter effects #217
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
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # .eslintrc.js # src/types.ts
src/core/create-storage.ts
Outdated
| }) as Effect<State, void, any> // as Effect<State, void, Fail<Err>> | ||
|
|
||
| const removeFx = attach({ | ||
| mapParams: () => undefined as any, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid that using undefined as new storage value will break synchronization across different persisted entities... I thought about adding extra support from adapter, like, adding removeItem support for localStorage and sessionStorage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to fix this by adding remove method to adapter, and removeFx calls it, or, in case it is absent — set method with null. Not sure I like it or not. Tried on memory adapter, will add for other adapters later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After tests approach didn't work with storage adapter (localStorage/sessionStorage) though... Cannot think of a way to notify persisted stores about removing value from storage. Will try smth else.
# Conflicts: # .size-limit.js # src/broadcast/index.ts # src/core/index.ts # src/core/persist.ts # src/index.ts # src/local/index.ts # src/memory/index.ts # src/query/index.ts # src/session/index.ts # src/types.ts
# Conflicts: # tests/core-validate.test.ts
# Conflicts: # tests/broadcast.test.ts # tests/local.test.ts # tests/memory.test.ts # tests/query.test.ts # tests/session.test.ts
fixes #216
Changes since @yumauri contribution to the branch:
removeEffect which is settingundefinedto storage valueclearEffect because it has to affect all storage, but current API assumes that Effects can affect only a particular entry with provided keyget->getFxset->setFxremove->removeFx