map To Single
Maps the first row of this KQLiteCursor into a single object of type T using mapper.
This is a terminal operation that expects exactly one row in the result set.
Cursor lifecycle
The KQLiteCursor is automatically closed after execution, regardless of whether an exception is thrown.
This uses use to ensure resource safety.
Characteristics
Strict: Throws an NoSuchElementException if the cursor is empty.
Strict: Throws an IllegalArgumentException if the cursor contains more than one row.
Safe: Ensures the cursor is closed immediately after the mapping attempt.
Return
The single mapped element of type T.
Author
MOHAMMAD AZIM ANSARI
Parameters
Transforms the cursor row into T.
See also
Throws
if the cursor is empty.
if the cursor has more than one row.
Maps each emitted KQLiteCursor from the upstream Flow into a single object of type T.
Each cursor emission is expected to contain exactly one row. The cursor is fully consumed and automatically closed after reading one row.
Cursor lifecycle
The KQLiteCursor is automatically closed after execution, regardless of whether an exception is thrown.
This uses use to ensure resource safety.
Threading
Mapping is executed on Dispatchers.IO by default.
A custom dispatcher can be provided to control threading.
Uses flowOn to shift upstream execution.
Characteristics
Strict: Throws an NoSuchElementException if the cursor is empty.
Strict: Throws an IllegalArgumentException if the cursor contains more than one row.
Safe: Ensures the cursor is closed immediately after the mapping attempt.
Return
A flow emitting a single object of type T for each cursor emission.
Author
MOHAMMAD AZIM ANSARI
Parameters
Optional CoroutineDispatcher for upstream execution (defaults to Dispatchers.IO).
Transforms the single cursor row into T.