Hey, I am currently migrating to the latest versio...
# javascript
h
Hey, I am currently migrating to the latest version (from v2025.7.15). I am a little confused how the new data loaders work. Before I had it like this for example:
Copy code
val 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)
}
e
I suppose this is related to kotlin-wrappers right? That declaration seems to come from the legacy router types that were removed in favor of TanStack Router.
h
Yes I am trying to migrate it to the latest version, this example is from the legacies before. It seems I have followed the wrong path down the types, before it was something like
() -> Unit
. But now I found
RouteLoaderFn
that provides options and expects a PromiseResult. Seems like this is correct(?) for now
Copy code
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.
e
@turansky probably Victor knows how to translate that as my React knowledge is very limited.
t
RouteLoaderFn
wrapper will do required work (it will create promise).
PromiseResult
call is redundant.
Just return
secureApi(endpoint)
Or
null
h
Oh, thanks! Sorry for the interruption ❤️
t
Our goal - Kotlinish API. And we create wrappers like this for your comfort.
K 1
If in some case it doesn't look cool - please report.
h
Yeah that's the one I found after searching some more. Don't know where the follow reference function from IDEA put me to find the other stuff. This makes way more sense.
t
Looks like you saw private signature 😞