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(with-storage-sync): indexeddb support #129

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

mzkmnk
Copy link

@mzkmnk mzkmnk commented Jan 18, 2025

Issue

#111

Content

const TodoIndexedDBSync = signalStore(
  withState<...>({...}),
  withStorageSync(
    {
        dbName:'ngrx-toolkit',
        storeName:'users',
    },
    withIndexedDB(),
  ),
  withMethods((store) => ({...}))
);

@mzkmnk mzkmnk force-pushed the feat/add-dexie-support branch from df518ef to df5449c Compare January 19, 2025 04:30
Copy link
Collaborator

@rainerhahnekamp rainerhahnekamp left a comment

Choose a reason for hiding this comment

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

@mzkmnk looks good, but I initially meant that we integrate this into the existing withStorageSync. Like how withGlitchTracking or withDisabledNameIndices is done for withDevtools.

You will very likely have to adapt the code of withStorageSync to make this happen.

The reason for not bringing up a second storage syncer extension is that we can reuse parts of its code (like serialization)

@mzkmnk
Copy link
Author

mzkmnk commented Jan 19, 2025

@rainerhahnekamp
I’m going to create a withIndexedDB to integrate with withStorageSync, taking inspiration from withDevtools, withGlitchTracking, and withDisabledNameIndices! It might take some time though… :)

@mzkmnk mzkmnk changed the title feat(with-indexeddb-sync): indexeddb support feat(with-storage-sync): indexeddb support Jan 19, 2025
@rainerhahnekamp
Copy link
Collaborator

@mzkmnk

It might take some time though… :)

Sure, if you have some work to delegate to me, let me know.

@audhit
Copy link

audhit commented Jan 20, 2025

@mzkmnk great work mate :) Thanks a lot. Hi @rainerhahnekamp can you please guide me how to use it and which version of the toolkit has this feature? Will it gonna be 19.0.3 ? Please let me know. Thanks in advance 🙏

@rainerhahnekamp
Copy link
Collaborator

@audhit it is still in development. Once @mzkmnk is done, he will push the "Ready for review" button.

@mzkmnk
Copy link
Author

mzkmnk commented Jan 20, 2025

@rainerhahnekamp
I’ve finished the withIndexedDB method (although I haven’t written any tests yet). I’m planning to do some more refactoring—do you have any advice? Also, do you think it would be acceptable to wrap the read and write methods of withStorageSync in something like Promise.resolve() so that they are handled asynchronously?

@mzkmnk mzkmnk force-pushed the feat/add-dexie-support branch from b677206 to 03298f8 Compare January 21, 2025 13:39
@rainerhahnekamp
Copy link
Collaborator

@mzkmnk big thanks for now. I will check the code asap and i do understand the potential necessity of async methods.

@mzkmnk mzkmnk force-pushed the feat/add-dexie-support branch from 2876625 to af02b32 Compare January 22, 2025 01:05
@mzkmnk mzkmnk force-pushed the feat/add-dexie-support branch from ea3cf84 to 8d0d308 Compare January 22, 2025 03:46
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.

3 participants