-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Description
If we know the set of variables captured by a keyed
, we can be smarter about when it is reevaluated.
As an example:
deft render(assigns) do
for post <- assigns.posts do
keyed post.id do
%{
id: post.id,
name: post.name,
}
end
end
end
If we know that the keyed post.id
block only uses state from within post
, and we know post
has not changed since the last render, we can omit rendering that subtree entirely.
This is a simple example, so omitting rendering the subtree would not give us much here, but when scaled to deeper and more complicated data structures, being able to omit rendering subtrees like this could be a major advantage.