Skip to content

feat(immer): initial#54

Draft
raveclassic wants to merge 4 commits intomasterfrom
immer
Draft

feat(immer): initial#54
raveclassic wants to merge 4 commits intomasterfrom
immer

Conversation

@raveclassic
Copy link
Copy Markdown
Owner

No description provided.

@nx-cloud
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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