menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

A mid-care...
source image

Dev

3w

read

192

img
dot

Image Credit: Dev

A mid-career retrospective of stores for state management

  • The use of sophisticated stores can establish a view-level source of truth to organise feature-specific state, especially when an app requires different parts to access information specific to a particular function.
  • Angular’s MVC structure movements service classes that perform state passing between views; instead of sophisticated stores, observables with RxJS were used to subscribe to streams of asynchronous event data.
  • The disaster that arose from not using a state management solution led to long-winded, overly imperative ('if-abc, else if xyz, else if jkl...'), and much harder to maintain and debug code.
  • Stores that are not well-architected can act like daisy-chained information flows, leading to confusion and harder maintenance.
  • Creating a store for every app feature can lead to unnecessary complexity and coupling.
  • Using a store for state management is ideal when there is complex, domain-specific logic that needs to be updated carefully.
  • React's hooks and Context API and Vue's computed(), ref() and watch() functions offer 'lightweight' options for state management.
  • Where needed, it is wise to choose a strategy before entropy takes hold.
  • Frameworks aim to reactively update the UI when the data changes, manage side effects, and distinguish between local, shared, and global state.
  • It is easy to get to a place where no single pattern is used, and it may become unsustainable to manage state within one or two components, and this is where a store would help.

Read Full Article

like

11 Likes

For uninterrupted reading, download the app