gajus / canonical-reducer-composition

Spec for Canonical Reducer Composition design pattern.
187 stars 3 forks source link

How to construct the initial state for a large application? #2

Closed kwhitaker closed 9 years ago

kwhitaker commented 9 years ago

The answer to this might be self-evident and I'm just missing it, but...

If I have a complex app with many pieces of state to be tracked (dashboard, admin, blog, comments, etc...), what's an effective strategy for building the initial state with CRC? Vanilla redux encourages me to manage the initial states for those pieces as part of the reducer setup:

let initialState = {
  isFetching: false,
  comments: []
}

export function comments(state=initialState, action) {...}

This keeps things tidy and "near" the concerns the initial states affect. It seems like CRC wants me to break those initial states out and construct a large tree elsewhere.

gajus commented 9 years ago

@kwhitaker Sorry, did not see the question earlier.

See, https://github.com/gajus/canonical-reducer-composition/issues/1. Please contribute to the discussion. As soon as the consensus is met, I will implement the feature.

gajus commented 9 years ago

https://github.com/gajus/canonical-reducer-composition/blob/master/README.md#construct-action-handler