Patch Struct

#include <vpatch.h>

Public Members

PatchOp op
std::string path
std::string parentPath
int index = 0
int node

Detailed Description

Patches are applied by reconcilers to update live widgets instead of rebuilding the whole tree every render.

Each patch is a specific operation (op) that needs to be applied to a target node identified by path. Patches that insert or replace nodes in the tree have a parentPath identifying the container to insert into and the node itself (new one or the replacement), with insert patches specifically including an index.

Most patches are inferred from a core diff of the previous resolved render tree against the new one. Others are queued after the diff patches from specific function calls like how PatchOp::EditorValue patches are pushed by VApp::push_editor_text(). The order is significant because if the same render needs to rebuild the editor due to a diff patch, that needs to apply before passing the new editor value to the reconstructed editor.

Reconcilers must apply patches in the order given, since each one assumes the earlier ones were applied. For example, within each parent, the diff emits removal patches before insert ones, so index is the position in the new child list.

Member Variable Documentation

PatchOp op

Operation to apply

std::string path

Identifies the target node

std::string parentPath

Identifies the parent node to insert node into. An empty value means the target is the root itself.

int index = 0

Insert only: Position among the parent's children to insert node into.

int node

Node containing the patch data.

What the node contains depends on the operation:

Operation node is ...
Insert/Replace Full subtree
Update Properties only
EditorValue Only text
Remove Not used
Appearance
Theme
—