Methods
(static) __onApiPromiseDone(event) → {void}
Render-thread handler — pool response arrived (isDone fired on the result node). Runs in the owning component's m. event.getNode() = the result node's id = the requestId we tagged in fetchAsync.
| Name | Type | Description |
|---|---|---|
event | object |
- Source
- Type:
- void
(static) __onApiPromiseTimeout(event) → {void}
Render-thread handler — the timeout timer fired before a response arrived. Runs in the owning component's m. event.getNode() = the timer's id = the requestId.
| Name | Type | Description |
|---|---|---|
event | object |
- Source
- Type:
- void
(static) abandonApiPromises() → {void}
Abandons every pending request owned by the current m: unobserves each result node's isDone, stops + unobserves each timeout timer, and clears the registry. After this, a late pool response settles nothing — the promise is left pending forever (its callbacks never fire into the now-dead component).
Call from the owning component's teardown (onDestroy). Safe to call when no requests are pending (no-op). Idempotent.
- Source
- Type:
- void
(static) abandonApiPromisesIn(pending) → {void}
Core abandon over an explicit registry — see settleApiPromiseIn for why the registry is a parameter. Clears pending IN PLACE (Clear(), not reassignment) so the caller's reference is emptied without depending on m.
| Name | Type | Description |
|---|---|---|
pending | object |
- Source
- Type:
- void
(static) apiPromiseShouldResolve(res) → {boolean}
Pure decision for the error contract (decision #5): does this pool result represent an HTTP response we should RESOLVE with?
• invalid → false (no response — timeout / abandoned slot) • statusCode <= 0 → false (transport failure — roku-requests reports a non-positive response code when no HTTP reply arrived) • statusCode > 0 → true (any HTTP status, incl. 4xx / 5xx)
| Name | Type | Description |
|---|---|---|
res | dynamic | the ApiResultNode.result AA, or invalid |
- Source
true to resolve, false to reject
- Type:
- boolean
(static) buildApiPromiseError(requestId, reason) → {object}
Builds the rejection error AA for the failure cases that don't carry an HTTP response (pool unavailable, timeout). Mirrors the response AA shape enough that .catch handlers can branch on err.reason / err.statusCode.
| Name | Type | Description |
|---|---|---|
requestId | string | |
reason | string |
- Source
- Type:
- object
(static) fetchAsync(req, requestId) → {object}
Submits an API request to the pool and returns a Promise for its completion.
Must be called from the render thread of the owning component (it registers a render-thread observer whose handler runs in that component's m). The pool itself does the I/O on a Task thread — the render thread never blocks.
response, rejects with an error AA on transport failure / timeout.
| Name | Type | Description |
|---|---|---|
req | dynamic | request AA from a Build*Request() method |
requestId | string | unique string identifying this request (registry key) |
- Source
a promises_Promise node; resolves with the response AA on any HTTP
- Type:
- object
(static) settleApiPromiseIn(pending, requestId) → {void}
Settles (resolve OR reject) the pending request identified by requestId, then tears down its observers + timer and drops the registry entry. Idempotent by design: the entry is removed first, so a second call (e.g. the timeout firing just after isDone) is a no-op.
pending is passed explicitly (rather than read from m) so the resolve / reject contract is unit-testable without relying on m propagation — bare calls from a Rooibos class method don't share the instance m, but production observer handlers (above) always pass their component's m.__apiPromisePending.
| Name | Type | Description |
|---|---|---|
pending | object | |
requestId | string |
- Source
- Type:
- void