UCE Docs / ONCE

Signature

ONCE(Request& context)

Defines a request-local one-time hook for the current .uce unit.

When a request first enters a given file through RENDER(Request& context), COMPONENT(Request& context), or any COMPONENT:NAME(Request& context) handler, the runtime checks whether that unit exposes ONCE(Request& context). If it does, the hook runs before the selected render or component handler.

ONCE() is tracked per request and per resolved unit file, so repeated component calls to the same file inside one request do not rerun it.

Typical Uses

  • prepare request-local derived state on context.call

  • load request-scoped config or data needed by multiple named component handlers

  • normalize shared props before the unit's first render/component call

Example

Example

print("ONCE is a unit directive; place it at top level in a .uce unit.\n");
Output
ONCE is a unit directive; place it at top level in a .uce unit.