-
Notifications
You must be signed in to change notification settings - Fork 8
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(immer): initial #54
base: master
Are you sure you want to change the base?
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit d8922d8. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 3 targetsSent with 💌 from NxCloud. |
recipes, | ||
(recipe) => | ||
(...args) => | ||
input.set(immer(input.get(), recipe(...args))), |
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.
Why not modify?
input.set(immer(input.get(), recipe(...args))), | |
input.modify(immer(recipe(...args))), |
interface Recipe<Value> { | ||
// any is needed due to variance | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(...args: readonly any[]): (draft: Draft<Value>) => void |
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.
We can use the immer syntax for this recipe
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.
It's simpler, see doc
{
toggleTodo: (draft, id) => {
const todo = draft.find(todo => todo.id === id)
todo.done = !todo.done
}
}
No description provided.