Closed iamcalledrob closed 2 months ago
I'm generally not a big fan of APIs with this shape, because it's easy to get errors if the type-parameter is inferred incorrectly. If you feel differently, it's easy enough to add the extension in your own code.
The reason the functions in Operators.kt
exist is because when using operator syntax, there's not always a clean way to indicate the type without having a generic function like this. But that's a special case and I'd rather avoid adding other similar APIs.
In Operators.kt, there is a generic get/set which works for primitive types.
It would be convenient to have the same functionality for the flow/coroutine getters too, so it can be kept in sync with the supported primitive getters/setters.
For my use-cases, I implemented it as follows:
My underlying use-case is a
getMutableStateFlow
for a setting, so it can easily be observed/set from compose UI.Implementation for the curious
```kotlin private inline fun