TheArchitect123 / KmpEssentials

KmpEssentials is a library that contains apis (40+ Modules) to accelerate your development. Everything from managing the Battery, File System, getting Package information, or taking Photos. Supports iOS, Android & AppleWatch
MIT License
214 stars 4 forks source link

[Feature] Adding optional DefaultValue in KmpPublicStorage and KmpSecureStorage #26

Open Monigan opened 7 hours ago

Monigan commented 7 hours ago

Hello! I think it would be nice if the library provided a setting of optional default values when getting values from storage. This could be useful to avoid having to write some logic in the application and returning null, when the app is waiting for a non-null or non-empty value.

Example: fun getStringFromKey(key: String, defValue: String?): String? actual fun getStringFromKey(key: String, defValue: String?): String? { return sharedPreference.getString(key, defValue) } actual fun getStringFromKey(key: String, defValue: String?): String? { return NSUserDefaults.standardUserDefaults.stringForKey(key) ?: defValue }

If I don't a right, please let me know so we can discuss about this feature.

TheArchitect123 commented 6 hours ago

Sure, I'm busy working on the jvm apis for now. But if you want to add this feature, you can create a PR for it, and I'll take a look when I can.

Otherwise, I'll get to this after jvm is ready. I appreciate the feedback.