Company
Date Published
Author
Khalil Stemmler
Word count
2674
Language
English
Hacker News points
None

Summary

In Apollo Client 3, local state management enables view-layer components to subscribe to pieces of it, get notified when it changes, and re-render. This is achieved using cache policies and reactive variables. Cache policies are a way to customize reads and writes to the cache, allowing for the modeling of types and fields that might not exist as part of your data graph but do exist on the client-side. Reactive variables are containers for variables that we would like to enable cache reactivity for, providing a simple API to set or get values. By defining local state management, developers can build their entire app with local state, query it the same way they query remote data, and change it by importing it anywhere while maintaining a consistent fetching approach. Local state management is an important consideration in building client-side web apps, enabling better separation of concerns and improving code organization.