Skip to content

Kotlin: Inspect

inspect() answers the same five-field snapshot KizunaSyncInspector.snapshot() reads, as a plain JSONObject rather than the typed KizunaSyncInspectorSnapshot. Most apps call Inspector instead; this function is the one the typed reading is built on.

Examples#

Basic#

// app/src/main/kotlin/com/example/todo/TodoScreen.kt (excerpt)
val raw = kizunasync.inspect()
val depth = raw.optInt("depth", 0)

Parameters#

NameTypeRequiredDescription
(none)——This function takes no arguments.

Returns#

JSONObject, decoded from the engine's response, with these keys.

NameTypeRequiredDescription
queuedJSONArray—The head of the outbox, oldest first.
depthInt—The same count Outbox depth returns.
last_mutation_idString?—The exactly-once push watermark: the mutation id of the last entry the server confirmed applied, not the last mutation queued. null until a push lands.
cursorString—The durable pull cursor, also on Checkpoint.
client_idString—The client's current registered identity. It changes after Reset.

Errors#

CodeCondition
ENGINE_UNAVAILABLEThe bridge answered with bytes that do not decode to a JSON object.
ENGINE_UNAVAILABLEThe client has no engine because Initializing has not run.

Notes#

last_mutation_id is the watermark a completed push advances, not a record of what is queued. A device with ten mutations waiting in the outbox and none pushed answers null here even though depth reads 10. Inspector wraps this call, adds the bounded verdict ring, and answers a typed KizunaSyncInspectorSnapshot. Reach for inspect() directly only when the raw JSONObject is what the call site wants.

Found a problem? Edit this page on GitHub