Skip to content

FluxbaseResponse

//fluxbase-kotlin/io.github.nimbleflux.fluxbase/FluxbaseResponse

sealed interface FluxbaseResponse<out T>

The result type for all Fluxbase SDK operations — the Kotlin equivalent of the TS SDK’s { data: T; error: null } | { data: null; error: Error } union (sdk/src/types.ts:3904).

Instead of throwing, SDK methods return a FluxbaseResponse so callers can destructure the result:

val (session, error) = client.auth.signInWithPassword(...)
if (error != null) { ... }

This matches the TS pattern const { data, error } = await client.auth.signIn(...).

Success
Error
Name Summary
Error [jvm]
class Error(val error: FluxbaseError) : FluxbaseResponse<Nothing>
Failed result. Not a data class: Kotlin 2.2+ forbids the generated component1(): FluxbaseError from clashing with the inherited component1(): Nothing? — destructuring still works via the interface operators above.
Success [jvm]
data class Success<T>(val data: T) : FluxbaseResponse<T>
Successful result.
Name Summary
data [jvm]
abstract val data: T?
The data payload on success, or null on error. In the TS SDK this is the data field.
error [jvm]
abstract val error: FluxbaseError?
The error on failure. Null on success.
Name Summary
component1 [jvm]
open operator fun component1(): T?
Destructuring support: val (data, error) = result. Matches the TS const { data, error } = await ... pattern. These must be members (not extensions) for Kotlin to recognize them in destructuring declarations.
component2 [jvm]
open operator fun component2(): FluxbaseError?
getOrNull [jvm]
fun <T> FluxbaseResponse<T>.getOrNull(): T?
Returns the data on success, or null on error. Equivalent to result.data in the TS SDK.
getOrThrow [jvm]
fun <T> FluxbaseResponse<T>.getOrThrow(): T
Returns the data on success, or throws the error on failure.