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

Allow to change defaultStore in createAtom #392

Closed
artalar opened this issue Nov 1, 2021 · 0 comments · Fixed by #393
Closed

Allow to change defaultStore in createAtom #392

artalar opened this issue Nov 1, 2021 · 0 comments · Fixed by #393
Labels
good first issue Good for newcomers

Comments

@artalar
Copy link
Owner

artalar commented Nov 1, 2021

We need an option defaultStore in AtomOptions. With this a user may create own createAtom implementation with own store, which useful for its customization:

// utils/store.ts
export const store = createStore({
  onPatch: console.log
})

// utils/createAtom.ts
import {createAtom as createAtomOriginal} from '@reatom/core'
export const createAtom: typeof createAtomOriginal = (deps, reducer, options) =>
  createAtomOriginal(deps, reducer, {...options, defaultStore: store})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant