first draft but not working yet
This commit is contained in:
commit
b54c89c9c4
10 changed files with 380 additions and 0 deletions
18
store/index.js
Normal file
18
store/index.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { createStore } from 'zustand/vanilla'
|
||||
import { persist } from 'zustand/middleware'
|
||||
import { idbStorage } from './middleware/persistence.js'
|
||||
|
||||
export const store = createStore(
|
||||
persist(
|
||||
(set, get) => ({
|
||||
user: null,
|
||||
items: [],
|
||||
setUser: (user) => set({ user }),
|
||||
addItem: (item) => set(s => ({ items: [...s.items, item] })),
|
||||
}),
|
||||
{
|
||||
name: 'app-store',
|
||||
storage: idbStorage, // custom adapter (see below)
|
||||
}
|
||||
)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue