jcperez-ch / flaxs

const Flaxs = Flux + Redux.principles();
BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

Assure Immutability of nested reducers on MasterStore #2

Closed jcperez-ch closed 8 years ago

jcperez-ch commented 8 years ago

To assure immutability, we might need to leverage the use of Object.freeze every time we merge a new state.

We need to make sure as well that we can create nested namespaces like:

// user.js
flaxs.createReducer('user', (state, payload) => {}, { info: {}});

and

// userPreferences.js
flaxs.createReducer('user.preferences', (state, payload) => {}, { language: 'en', locale: 'en-CA' });

and at the end have a deep immutable state like:

{
    "user": {
        "info": {},
        "preferences": {
            "language": "en",
            "locale": "en-CA"
        }
    }
}
tomzmtl commented 8 years ago

I would also consider implementing a library like Immutable.js to make sure any data coming from the store cannot be altered.

jcperez-ch commented 8 years ago

Fixed in https://github.com/jcperez-ch/flaxs/pull/3