I am building an App that has same functionality as WhatsApp. I am using firebase(Online Mode) and Room(Offline Mode).
I want that my code should determine when to fetch the data from firebase and when the user is offline just store and show the data using Room Db and whenever the user goes online update in firebase.
Flow:
If Online:
Check if Database have changes if yes fetch data and store locally in Room.
Check if Room Db is changed if yes update UI. [UI should only get data from Room Db]
If Offline:
Store the data locally and change the UI instantly and whenever the user goes online update firebase.
If this is not the optimised solution in respect of App Performance. Please share your thoughts
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…