Appearance
Class: Prediction
A native Kappapps prediction. Use kapp.prediction.start(), get() or resume(). A restarted owner installation can explicitly resume control. Other installations cannot. Subscribe with onEnd() before closing: the callback can run before the HTTP promise settles. Reconnect/read participants to recover current state; live callbacks are not an audit log.
Properties
data
ts
data: PredictionData = null;FINISH_STATUS
ts
static FINISH_STATUS: string[];STATUS_ACTIVE
ts
static STATUS_ACTIVE: string = 'ACTIVE';STATUS_CANCELED
ts
static STATUS_CANCELED: string = 'CANCELED';STATUS_LOCKED
ts
static STATUS_LOCKED: string = 'LOCKED';STATUS_RESOLVED
ts
static STATUS_RESOLVED: string = 'RESOLVED';Methods
bet()
ts
bet(
user,
outcome_id,
amount?,
method?,
options?): Promise<void>;Immutable choice and stake. A reused idempotency_key recovers the same acknowledgement, including after closure, without another debit. Rejections expose code/reason/status.
Parameters
user
string | User
outcome_id
number
amount?
number = 0
method?
"id" | "login"
options?
ParticipationOptions = {}
Returns
Promise<void>
cancel()
ts
cancel(): Promise<void>;Refund all stakes atomically. END may arrive before the HTTP return.
Returns
Promise<void>
getData()
ts
getData(): Promise<PredictionData>;Refresh state. Read the returned status as well as listening to events.
Returns
Promise<PredictionData>
getParticipants()
ts
getParticipants(query?): Promise<ParticipantsPage<PredictionParticipation>>;Owner-only current/final participations; follow next_cursor to read every page (max 200/page).
Parameters
query?
ParticipantsQuery = {}
Returns
Promise<ParticipantsPage<PredictionParticipation>>
getTallies()
ts
getTallies(): PredictionTally[];Returns
lock()
ts
lock(): Promise<void>;Close participation and start auto_cancel_after.
Returns
Promise<void>
onEnd()
ts
onEnd(callback): () => void;Subscribe to resolution or cancellation. Returns an unsubscribe function. Register before closing: the callback receives this model and can run before resolve()/cancel() resolves. Locking is not an ending; past endings are not replayed. Also inspect data after the command or when reading an already finished prediction.
Parameters
callback
(prediction) => void
Returns
() => void
onParticipation()
ts
onParticipation(callback): () => void;Accepted live changes with revision/event_id for reconciliation. Returns an unsubscribe function.
Parameters
callback
(participation) => void
Returns
() => void
resolve()
ts
resolve(outcome_id): Promise<void>;Distribute gross payouts, rounded down per winner. No winner: full refund. END may arrive first.
Parameters
outcome_id
number
Returns
Promise<void>