import { App } from 'reapex'
import immer from 'reapex-plugin-immer'
const app = new App()
// 1. register the plugin
app.plugin(immer)
// 2. in mutations, we can expect the state it receives as an immer draft object
interface TodoState {
todos: string[]
}
const initial: TodoState = {
todos: [],
}
const TodoModel = app.model('todos', initial)
const [mutations] = TodoModel.mutations({
add: (todo: string) => state => {
// the state here is an immer draft
state.todos.push(todo)
return state
},
})
-
Notifications
You must be signed in to change notification settings - Fork 0
License
ReapexJS/reapex-plugin-immer
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published