https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
n

Nacho Ruiz Martin

10/21/2023, 9:16 PM
Hey! 👋 Not sure which channel would be the best for this. I’m having some trouble with Multiplatform Settings library (version
1.1.0
. I’m using
FlowSettings
with
DatastoreSettings
implementation. The thing is that when I listen for changes in a property with:
Copy code
settings.getStringOrNullFlow(key)
writing with:
Copy code
settings.putString(key, value) //This is a suspend fun
is blocked forever, it never ends. Am I the only one experiencing this? I did downgrade the lib to
1.0.0
and no change.
r

russhwolf

10/21/2023, 10:20 PM
Can you show more of the context where you’re calling things? I wonder if something’s deadlocking somehow. If you have a reproducer, I’d love to take a look.
n

Nacho Ruiz Martin

10/21/2023, 10:26 PM
The project is quite big and private repo so I don’t have a reproducer, sorry. Regarding the context: I’m using KoinDI to inject a singleton
FlowSettings
into a class instantiated as a factory (new instance each time is needed). This class contains a couple of methods, one of them to get the flow and the other one to put some value. At least two listeners are getting updates from the same flow and the lock happens when trying to write a value there. I just tried with
ObservableSettings
and it’s working as expected.
r

russhwolf

10/21/2023, 10:32 PM
DataStore only supports one instance at a time per file, so it’s possible using a new instance each time is your issue. But in that case I’d expect an exception rather than a freeze.
n

Nacho Ruiz Martin

10/21/2023, 10:35 PM
Datastore is actually only instantiated once because the
FlowSettings
is injected as a singleton.
r

russhwolf

10/21/2023, 10:35 PM
Oh i see. I misread your comment
It’s still hard to be very helpful without seeing more actual code.
6 Views