BreezeJS offline / online management

Background: I am ready to start a project that has a requirement for mobile first. I am using AngularJS for client side, SQL for DB and .net WEBApi2 for communication. I read about BreezeJS and would like to use it as my offline data processing function, primarily because I am using EF6 on the .NET side and I like the idea that Breeze can manipulate and create objects using EF metadata ...

While developing an application, I got stuck with the idea of ​​how to accurately manage sudden network loss. As I understand it, BreezeJS keeps its EntityManager in working memory as it is in use. If the user is online and then the browser crashes or the computer shuts down and then the web app is reopened offline, then Breeze is gracefully restored or used as a use case that I need to handle?

Question: I guess my question is simple, is there a way I can get BreezeJS NOT to use working memory, but instead work instead of localStorage? If not, should I export Entities to local storage for every change, or is there a better way to handle this particular use case?

+3


source to share


1 answer


Breeze cannot automatically work with localStorage, however you can create a timer that periodically stores the state of the EntityManager in localStorage. Not sure if this is a great idea.



You need to distinguish between the case where the server is not available, in which case it makes sense to store the EntityManager in localStorage so that you can save any changes when the server comes back. As opposed to worrying about browser / client crashing, in this case, I find it better to just not handle this case. The complexity and perfection effects are pretty big, and if you are really concerned about it then just save (to the server) after every change (again, not necessarily the recommended approach, but it is available).

+2


source







All Articles