Hildebrandt Tobias
04/01/2026, 1:03 PMval VehicleClassLoader = LoaderFunction<Array<VehicleClassDto>?> { args, _ ->
val vehicleClassId = args.params["id"]
if (vehicleClassId == "-1") return@LoaderFunction PromiseResult(null)
val endpoint = VehicleClassEndpoints.getVehicleClass.copy(
optionalQueryParams = pairListOf("id" to vehicleClassId.toString())
)
val vehicleClass = secureApi(endpoint)
PromiseResult(vehicleClass)
}Edoardo Luppi
04/01/2026, 1:09 PMHildebrandt Tobias
04/01/2026, 1:11 PM() -> Unit.
But now I found RouteLoaderFn that provides options and expects a PromiseResult.
Seems like this is correct(?) for now
val VehicleClassLoader = RouteLoaderFn { options ->
val vehicleClassId = options.params[ParamName("id")]
if (vehicleClassId == "-1") return@RouteLoaderFn PromiseResult(null)
val endpoint = VehicleClassEndpoints.getVehicleClass.copy(
optionalQueryParams = pairListOf("id" to vehicleClassId.toString())
)
val vehicleClass = secureApi(endpoint)
PromiseResult(vehicleClass)
}
Sorry for the trouble but the other type chain really confused me.Edoardo Luppi
04/01/2026, 1:12 PMturansky
04/01/2026, 1:15 PMRouteLoaderFn wrapper will do required work (it will create promise).
PromiseResult call is redundant.turansky
04/01/2026, 1:16 PMsecureApi(endpoint)turansky
04/01/2026, 1:16 PMnullHildebrandt Tobias
04/01/2026, 1:16 PMturansky
04/01/2026, 1:17 PMturansky
04/01/2026, 1:18 PMHildebrandt Tobias
04/01/2026, 1:40 PMturansky
04/01/2026, 1:42 PM