-
Notifications
You must be signed in to change notification settings - Fork 16
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
Remove atomified <-state, optimizations #42
Conversation
Will take a longer look soon, but after a quick glance, one thing that bothers (if I can say so) is the I haven't looked at the other changes yet in the PR. |
Perhaps you're right. We have an issue over at facebook/react#15154 where we're trying to figure out if there's some extra optimizations we can do w.r.t. state updates. I think that in practice, the chance that a state operation returns a structurally equivalent but referentially different value is rare. So might be good to keep the hot path clear of that. |
I've always thought that the user should be able to supply their own comparison function, because they're best positioned to know what kind of data structures they use on a case-by-case basis. So I think an API could look like so:
(the last case could be omitted as |
I would go further and provide nothing. The user can just do the custom comparison him/herself before calling |
I think that you will want to be able to do the quality check in the state computation, so that you can accommodate state changes occurring between when you call Another option for users is to use |
This MR removes the Atomified wrapper returned by
<-state
. It implements a couple of new features:<-state
returns a tuple[state set-state]
set-state
will prevent re-renders triggered by structurally equivalent state objectsset-state
can be used with multiple arguments likeswap!
:(set-state assoc :new-key "new-value")
<-value
hook that can be used to optimize<-effect
,<-memo
, etc.