-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Keyed updates #209
Keyed updates #209
Conversation
Current coverage is 92.60% (diff: 100%)@@ master #209 diff @@
==========================================
Files 71 71
Lines 1666 1690 +24
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 1541 1565 +24
Misses 125 125
Partials 0 0
|
Ans limitations oft how |
Currently yes. Could change it to any valid property name, though that could be done later - var names covers 99% of uses I think |
I like how you pass in / attach the key prop to sub-blocks :-) Using From the generated code:
That |
Yeah – I was finding things easier to follow when it's
Whoops! In a lot of cases we probably only need to pass the |
I actually find it easier to follow if you have one variable for each in generated code variable. Since syntax highlighting shows you the template string interpolations clearly, but suffixes tend to move into the background. Also its shorter to type :-) But I think its a matter of taste. |
This implements keyed updates, as discussed in #81. For now, it's a slightly naive implementation – it re-mounts each iteration every time the block updates, which in many cases is wasteful – but that's okay, since we can iterate on the performance aspects once we're happy that the behaviour is correct.
You opt in to keyed updates like so:
In this case, if an item was removed from the middle of the
todos
array, all<p>
elements would continue to represent the same todo item, as long as each todo item had anid
property. (The property doesn't need to be calledid
, of course.)sample code