Skip to content

bind + memoize? #68

Answered by Tao-VanJS
benallfree asked this question in Q&A
Jul 9, 2023 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

Alternatively, you can use Object.assign to do field-level state updates, something like:

const s = {
  a: van.state(1),
  b: van.state(2),
}

// To update `s` with values in `newS`
Object.assign(s, newS)

Note that the states won't be considered changed if their underlying values remain the same.

You can define your custom deep assignment functions if you need to.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@benallfree
Comment options

@Tao-VanJS
Comment options

@Tao-VanJS
Comment options

Answer selected by Tao-VanJS
@benallfree
Comment options

@Tao-VanJS
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants