Concepts

GState is extensively inspired by Command Query Responsibility Segregation pattern. The concept is a notation that you may have two different models: one optimized for read information and one to update information. It helps to solve many state management problems. One common issue is manage a collection of objects.

Storing collection as an object is easy for updating, but it is required to map to an array for rendering.

state.posts = {//collection of posts}
// map to array for display
Object.keys(state.posts).map(key => state.posts[key])

GState’s CQRS

Query: gstate uses a denormalized tree-liked model to read information. It borrows idea from Relay/GraphQL (and syntax from my NextQL). The model is match with what UI look like.

Command: gstate uses natural JS object model which is normalized and graph-liked. The model is natural JS objects which is easy for mutation.

results matching ""

    No results matching ""