NationalBankBelgium / stark

Modern client-side Web application framework based on Angular, Angular Material / Material Design, TypeScript, Redux, RxJS, ...
https://stark.nbb.be
Other
55 stars 23 forks source link

core: add support for LocalStorage, SessionStorage and IndexedDB #178

Open dsebastien opened 6 years ago

dsebastien commented 6 years ago

Discussion: add local storage / session storage support in stark or just let users use whatever they want for that? Argument: directly using the APIs could be dangerous as there are corner cases to handle (e.g., different errors depending on the browser when full or not available).

Bonus: add RxJS support to observe the local storage or part thereof

Good starting point: http://www.bennadel.com/blog/2861-encapsulating-localstorage-access-in-angularjs.htm

Some libraries could be looked into:

General refs:

If we know what we want to be using and how, we need to provide documentation by updating the documentation prepared by NG-1

We also need to update NG-39 and the doc it produced

dsebastien commented 6 years ago

Local forage Since dealing with offline storage can become really cumbersome, especially when dealing with session storage, local storage and indexed db at the same time, there are libraries that can assist developers. Localforage is one of those libraries, it basically encapsulates all the API's and lets you write code that approaches all of them in a uniform way. There are also some fallbacks included in this library, should any of the newer APIs like Indexeddb or Websql not be found (basically when dealing with older browsers). Usage of local forage is advised to reduce complexity of dealing with offline storage APIs. https://github.com/localForage/localForage

dsebastien commented 6 years ago

Maybe we come resurrect the idea of a "Stark Storage Service":

The service should include:

dsebastien commented 6 years ago

Check out https://github.com/btroncone/ngrx-store-localstorage