Unresolved
Details
Assignee
Hekmatullah AminHekmatullah AminReporter
Hekmatullah AminHekmatullah AminPriority
Minor
Details
Details
Assignee
Hekmatullah Amin
Hekmatullah AminReporter
Hekmatullah Amin
Hekmatullah AminPriority
More fields
More fields
More fields
Created March 2, 2025 at 2:32 PM
Updated March 6, 2025 at 9:03 PM
In the
core/datastore
module, I have integratedSuspendSettings
andFlowSettings
to enable flexible, reactive, and asynchronous settings management. Specifically, I introduced two generic functions:putSerializableData
: This function allows you to store any serializable data class (or primitive types) into the settings. It serializes the data to JSON format using the provided serializer and stores it as a string in the settings. This makes it easy to save complex data structures while keeping the implementation generic and reusable for different types of data.Example usage:
observeKeyFlow
: This function enables observing changes to any key in the settings. It supports both primitive types (such asInt
,Long
,String
,Float
,Boolean
) and serializable data classes. For serializable objects, it will serialize the default value to JSON and then decode it when changes occur. This ensures that any key in the settings can be observed reactively using aFlow
.Example usage:
By leveraging
FlowSettings
for observing key changes andSuspendSettings
for suspending data operations, these additions improve the handling of both asynchronous data management and real-time observation of changes. This approach allows for easily saving and observing complex data types, reducing boilerplate and making the code more maintainable and extensible.Now, with these utility functions in place, saving and observing serialized data or primitive types in the settings has been greatly simplified, providing a more consistent and reusable mechanism for managing settings across the application.