GitLiveApp / firebase-kotlin-sdk

A Kotlin-first SDK for Firebase
https://gitliveapp.github.io/firebase-kotlin-sdk/
Apache License 2.0
1.14k stars 155 forks source link

RemoteConfig - setDefaults. Does it need to be "suspend" or am I doing this wrong? #639

Open Monabr opened 1 month ago

Monabr commented 1 month ago

Hello.

In an Android project I got a RemoteConfig in classes using DI. In it I configured the RemoteConfig in the module specifying the update period and default values.

I did the same using your library. During the migration I found that the setDefaults function has now become a suspend function. At first this puzzled me a lot because functions in the DI module cannot be suspend. I solved this situation by using runBlocking.

Despite my decision to use runBlocking I still doubt this method.

mr-kew commented 2 weeks ago

Well setDefaults is suspend because on android it uses setDefaultsAsync that returns Task. If you didnt process the Task on android, then you should use launch instead of runBlocking when using suspend to do like a fire and forget.