The current approach using extension functions for decoding JSON from SavedStateHandle involves repetitive code and adds complexity to our tests. We need to stub the JSON data in each test case individually, which is inefficient and error-prone.
Solution
@ViewModelScoped
class RouteParamProvider @Inject constructor(
val savedStateHandle: SavedStateHandle,
) {
inline fun <reified T> decode(key: String): T {
val jsonString = savedStateHandle.get<String>(key) ?: throw IllegalArgumentException("Argument not found")
return Json.decodeFromString(jsonString)
}
}
Additional context
No response
Code of Conduct
[X] I agree to follow this project's Code of Conduct and Contributing Guidelines
Problem
The current approach using extension functions for decoding JSON from SavedStateHandle involves repetitive code and adds complexity to our tests. We need to stub the JSON data in each test case individually, which is inefficient and error-prone.
Solution
Additional context
No response
Code of Conduct