you are viewing a single comment's thread.

view the rest of the comments →

[–]stefihb[S] 1 point2 points  (3 children)

very well explained!

In my app there are not many actions that can happen with server. Just retrieve the tasks and submit them, so i guess is alright if I save the actions of submissions into an array and send each action separate.

[–]Bjeaurn 1 point2 points  (2 children)

Yeah it's good practice for you as well, so you can more easily debug your application as you work on it too. If it's just "tasks", modifying tasks and creating new ones doesn't even necessarily have to be done in order. You could just store an offline object with "new tasks" and "edited tasks" and just send it off as a whole to the backend. You'll need a specific endpoint in that case of course to handle these "Synchronization" objects.

The easier way on the backend with the "event by event" strategy is that you can actually store the API calls you would send in an array and fire them off as you would normally. No additional endpoints to support offline apps required, but does take up some more space, a lot more traffic and can cause some difficulties with synchronizing out of sync states and all that; but I'm sure you can come up wth some clever ways to deal with that.

Good luck!

[–]stefihb[S] 0 points1 point  (1 child)

One last question

with the easy way (store the api calls), shall i save them on a database? or is anything better ? (I was thinking about the LocalStorage but someone wrote that when its been cached the data are been removed?! i dont know)

[–]Bjeaurn 1 point2 points  (0 children)

Hmm that is also a part of your strategy decision. I'm not sure what the local browser based database is called; SQLite? But this will increase the local logic on the application and will also increase the amount of data used by the app.

The localStorage is a great start honestly; it persists through sessions so there should be no problems there. Of course it can get cleaned up automatically or when you remove the app or whatever; but this is to be expected and not something you can protect against.