Skip to content

State Management with Akita

RYU Chua edited this page May 3, 2020 · 2 revisions

Previously Gauzy has its own App State Management using BehaviorSubject from RxJS which is nothing wrong. However, at anytime we are not so sure about what is in the "State", to fix that, a very simple and easy to use State Management library Akita is applied, and no worry, no breaking changes at all, at least yet to found. (** except adding new library, so kindly run yarn install if use not yet do so.

To view the state, kindly install this ReduxDevTools Chrome Extension.

We are not using "Redux", so why install this?

Well, because Akita make use of this extension to show the "States" as well, so we can now see very clearly our App State in Chrome Inspect "Redux" tab, as below: image

Implementation Brief

  • The Store is being split into 2 "stores" one call "AppStore", another call "PersistStore", the PersistStore as its name, will be persisted into localStorage, which store only the "token", "userId", and "serverConnection" for now, and we can further improve to store selectedLanguage, selectedTheme, and so on, but DO NOT over persist everything, just do when necessary.
  • The Store Service Code is fully revamped to seamlessly replace all existing getter/setter method and "BehaviorSubject"s in the Store class with the "Store" & "Query" class provided from Akita.

feel free to visits the exact changes in this PR #1128

For more details and actual proper usage of Akita, kindly refer the official docs