Docs Client library reference Swift
v0.2.6-alpha.3Swift: Outbox depth
outboxDepth() counts the queued mutations that no run has settled. It is the number a screen shows as pending work, and it reaches zero once every write has an applied or rejected verdict.
Examples#
Basic#
// TodoApp/TodoListView.swift (excerpt)
import KizunaSync
let pending = try await kizunasync.outboxDepth()Keep a badge in sync#
// TodoApp/TodoListView.swift (excerpt)
import KizunaSync
let stop = try await kizunasync.on { event in
if case .queueDepth(let depth) = event {
Task { @MainActor in badge = Int(depth) }
}
}Parameters#
| Name | Type | Required | Description |
|---|---|---|---|
(none) | — | — | This method takes no arguments. |
Returns#
Int, the number of outbox entries that are not in flight. A write that a push is carrying right now is not counted, so the number drops as verdicts arrive rather than after the whole run finishes.
Errors#
| Code | Condition |
|---|---|
STORE | The local database could not be read. |
ENGINE_UNAVAILABLE | The client has no engine because Initializing has not run. |
Notes#
Every successful write raises QUEUE_DEPTH with the same number, so a view can follow the count through Subscribe to events instead of polling this method. A depth that never falls means the runs are failing; the reason is in the last error a run threw, and a write the retry budget finally dropped appears in List rejections with kind DEAD_LETTER.
The count says nothing about attachment bytes. An upload that is queued after the outbox drains is tracked by Get attachment status.
Related reference#
Found a problem? Edit this page on GitHub