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(immer): initial #54

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

feat(immer): initial #54

wants to merge 4 commits into from

Conversation

raveclassic
Copy link
Owner

No description provided.

@nx-cloud
Copy link

nx-cloud bot commented Apr 21, 2022

☁️ Nx Cloud Report

CI 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 targets

Sent with 💌 from NxCloud.

@Fyzu Fyzu self-requested a review April 25, 2022 09:19
recipes,
(recipe) =>
(...args) =>
input.set(immer(input.get(), recipe(...args))),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not modify?

Suggested change
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
Copy link
Collaborator

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

Copy link
Collaborator

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
  }
}

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.

2 participants