Lifecycle
Each node can run callbacks while Qore handles a node request and while it prepares the node response.
Use request callbacks for incoming state, such as button clicks or form interactions. Use response callbacks for derived output, such as table pagination, disabled dates or final node properties.
Request pass
- 1Node
$node->onNodeRequest()current nodeCallbacks registered on the current node run in registration order. On the initial request, default visibility is applied immediately before them. - 2Node
$child->onNodeRequest()each childThe first child's complete subtree runs parent-first, then the next sibling's subtree runs.
Response pass
- 3Node
$node->onNodeResponse()current nodeAfter the entire request pass has finished, callbacks on the current node run in registration order. - 4Node
$child->onNodeResponse()each childThe first child's complete subtree runs parent-first, then the next sibling's subtree runs.
Finish
- 5Node
$root->setOnBeforeResponseCallback()root onlyThe optional root callback runs once, after both complete tree passes. - 6Framework
NodeManager::toArray()The visible tree and response state are serialized, then the node registrar is cleared.
root.request → child.request → grandchild.request → root.response → child.response → grandchild.response → root.beforeResponse → serializeHidden nodes still run request and response callbacks. Visibility only removes them during serialization.
On Node Request
Runs before serialization, while the backend is handling incoming node state. For example, ButtonNode checks whether the user clicked it:
$myNode->onNodeRequest(function (NodeManager $manager) {
if (! $manager->getStateByKey($this->id)) {
return;
}
$listener = $this->onClickListener;
$listener(new ClickEvent($this, $manager));
});
On Node Response
Runs after request callbacks and before serialization.
For example, EloquentTableNode uses this stage to handle pagination, sorting and filtering:
$myNode->onNodeResponse(function (NodeManager $nodeManager) {
$this->handleTableResponse($nodeManager);
});
Fields inside a FormNode add form-specific callbacks between the normal node request and response passes. See Field Lifecycle for their complete order.