Methods
(static) SubmitSideEffect(req) → {void}
Submits a fire-and-forget request to the global SideEffectTask. No response is observed. Calls are serialised — do not use for cancellable UI requests.
| Name | Type | Description |
|---|---|---|
req | dynamic | request AA: { method, url, headers?, body?, timeout? } |
- Source
- Type:
- void
(static) fetchJson(req, requestId) → {dynamic}
Convenience wrapper — submits via the queue and returns the parsed JSON body. Returns invalid on timeout, HTTP error, or if req is invalid.
| Name | Type | Description |
|---|---|---|
req | dynamic | request AA from a Build*Request() method |
requestId | string | unique string identifying this request |
- Source
res.json or invalid
- Type:
- dynamic
(static) fetchRes(req, requestId) → {dynamic}
Submits a request to the API queue coordinator and blocks the calling Task thread until the response arrives (or the timeouts.API_WAIT_MS deadline elapses).
Safe to call concurrently from multiple Task threads — each request gets its own ApiResultNode, so responses are never mixed up between callers. The coordinator (ApiQueueTask) is the only entity that dispatches to pool slots, eliminating the TOCTOU race that existed when callers claimed slots directly.
Delivery mechanism: the ApiResultNode is appended as a CHILD of the coordinator node. This is immune to SceneGraph port-event coalescing — even if multiple concurrent enqueue wakeup events merge into one, the coordinator reads ALL unprocessed children when it wakes up, so no request is ever lost.
| Name | Type | Description |
|---|---|---|
req | dynamic | request AA from a Build*Request() method; returns invalid if invalid |
requestId | string | unique string identifying this request (echoed in the response AA) |
- Source
response AA { requestId, ok, statusCode, json, text } or invalid on timeout (timeouts.API_WAIT_MS)
- Type:
- dynamic
(static) submitApiRequest(req, requestId) → {dynamic}
Submits a request to the API queue coordinator and returns immediately without blocking. The caller observes 'done' on the returned ApiResultNode via a render-thread callback, then reads 'result' for the response.
The render thread does NOT make the HTTP call — it just creates a node, appends it to the coordinator, and returns (~microseconds). The coordinator (ApiQueueTask, a Task thread) dispatches to an ApiTask pool slot (another Task thread) which performs the actual HTTP request. When done, the result is written back to the ApiResultNode and the render-thread observeField callback fires.
Use for single API calls with trivial callbacks (set a boolean, read one value). Do NOT use when the callback needs data transforms or array processing — use an Orchestrator Task with fetchJson() instead.
| Name | Type | Description |
|---|---|---|
req | dynamic | request AA from a Build*Request() method; returns invalid if invalid |
requestId | string | unique string identifying this request |
- Source
ApiResultNode to observe, or invalid if the pool is not ready
- Type:
- dynamic