requestUpdateFor method
Granular update — re-renders and diffs only component's subtree.
The browser only sees changes inside the single DOM node that belongs
to component. Nothing outside it is touched.
Implementation
void requestUpdateFor(Component component) {
if (!_mounted) return;
if (component == rootComponent) {
_requestRootUpdate();
return;
}
final domNode = _componentNodes[component];
final prevTree = _componentTrees[component];
if (domNode == null || prevTree == null) {
_requestRootUpdate();
return;
}
RenderContext.run(this, () {
RenderContext.runWithComponent(component, () {
final result = resolveNode(ComponentRenderNode(component));
switch (result) {
case ResolveSuccess(:final tree):
patch(domNode, prevTree, tree);
_componentTrees[component] = tree;
component.onMorph();
case ResolveFailure(:final error, :final failedComponent):
// Granular update failure is non-fatal — the component stays in
// its last valid state. Log and continue.
// ignore: avoid_print
print(
'Pulsar: morph failed for '
'${failedComponent?.runtimeType ?? component.runtimeType}: '
'$error',
);
}
});
});
}