Add core/datastore module

Description

None

Activity

Show:

Hekmatullah Amin March 5, 2025 at 5:12 PM

In the core/datastore module, I have integrated SuspendSettings and FlowSettings to enable flexible, reactive, and asynchronous settings management. Specifically, I introduced two generic functions:

  1. 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:

  2. observeKeyFlow: This function enables observing changes to any key in the settings. It supports both primitive types (such as Int, 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 a Flow.

    Example usage:

By leveraging FlowSettings for observing key changes and SuspendSettings 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.

Unresolved

Details

Assignee

Reporter

Priority

More fields

Created March 2, 2025 at 2:32 PM
Updated March 6, 2025 at 9:03 PM