Hello, using <https://github.com/russhwolf/multipl...
# multiplatform
g
Hello, using https://github.com/russhwolf/multiplatform-settings and its serialization API with
encodeValue
and
decodeValueOrNull
functions, how to I make an observable version of
decodeValueOrNull
? There's a coroutines module but I haven't found the intersection between that module and the serialization module? 🤔 cc @russhwolf 😇
t
Is the
ObservableSettings
type not working with
observableSettings.get<Type>Flow("key", defaultValue)
? https://github.com/russhwolf/multiplatform-settings?tab=readme-ov-file#coroutine-apis
g
Hmmm it's not a "classic" type, it's a class of mine, so those functions can't return any type, or I missed the one that can?
Instead I am now storing the properties directly, and on those we do have
get<Type>Flow
. I guess the way the modules are built, there should be a serialization-coroutines module to mix the two. I'll open a ticket!
r
Sorry. It's a difficult API to design in a way that works for all implementations, and it hasn't been a high priority yet compared to stabilizing some other things.
g
Ah, sorry to hear 😞 Even if it would be part / extension of
multiplatform-settings-make-observable
?
r
That module doesn't really impact things. The issue is that serialization listeners work better if you have an untyped
addListener
function (which existed in earlier versions of the library), but that makes it harder to convert between
ObservableSettings
and
FlowSettings
. One solution is to add listeners at every key of the serialized type, but that requires some work coercing the serialization machinery into doing what we need.
g
I see, thanks for the explanation 🙏