1

So I'm reading about Optimistic UI and it's something I would like to implement in my android java app.

My android app connects with my rest api. My confusion is how do I go about this?

I have a products api that I call from the android app to save data. How do I do this using the optimistic ui approach.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
user3718908x100
  • 7,939
  • 15
  • 64
  • 123

1 Answers1

0

The easiest way? I assume the rest API will either call a callback, or send a message some other way (like rxJava or a message bus). Have your rest API call the callback/send the message once with the optimistic result, then again with the real result.

Remember that the problem with an optimistic result is that its a (possibly educated) guess. It can be very wrong. So there's places where its a viable solution, and places it isn't. For example, a banking app shouldn't optimistically guess someone's balance. I'd say the number of places where it makes sense are dwarfed by the number it doesn't.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • 1
    So if I update the UI, the user leaves the page and comes back before the save operation is completed. How do I persist the modified data on the device? – user3718908x100 Sep 14 '19 at 23:18