79428944

Date: 2025-02-11 05:26:29
Score: 2.5
Natty:
Report link

Which option did you choose? I also encountered this situation. I use a third-party API that I cannot control. And, for example, I request a list of available devices. The API sends me a list of devices, but does not indicate their status (online, offline). You can make a request to the API for each device (by id). In this case, I get the device state. I decided to make the second request only when the user performs some action with the device (for example, turns it on). As a result, I get a situation where I have a list of devices without a state, and one device with a state. Accordingly, I need to update the list and notify the Ui layer about the change (and, in a good way, block the ability to act on the device). If we implement the cache simply as a list, as is done in the documentation, then when replacing a device in the list, we will not receive the changed data until we explicitly request it from the data layer. At the moment, I keep all the data on the ViewModel layer. For this reason, I have one ViewModel instance for several screens.

Reasons:
  • Blacklisted phrase (0.5): I need
  • Blacklisted phrase (0.5): I cannot
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Single line (0.5):
  • Starts with a question (0.5): Which
  • Low reputation (0.5):
Posted by: pie