After reading a lot of articles and documentation, finally, I think this is the recommended way of manage data in an app that has network repositories.
• have a local datasource which has the network content cached and updated periodically
• if the app user makes changes on the data that must be reflected on the UI, don't update the local datasource, instead, update the network data source, and the local datasource will be updated when the network data is received periodically
• then, when the local datasource gets updated, the flow will emit the new values to the UIstate and then the UI will get updated with the changes made. This will use the UDF and the SSOT patterns.
But I have a question, when should I update the cached local datasource? I mean... if it must be periodically... that can be done by a thread or something that each minute requests for new data to the server. How to do this correctly?
Also, another question. If a change is made to the data by the app user, and you must update the network datasource to get the local datasource updated automatically when it updates periodically, it can mean that it will take 1 minute to display the changes on the UI... or even more if the internet connection is not fast. Does that mean that I must update both datasources at once? local and remote?