Created
August 15, 2016 21:03
-
-
Save erichulburd/28a874730a16f2fb91919217b5ec415b to your computer and use it in GitHub Desktop.
Make sure to return Immutable objects in reducers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ensureProducts]: (products_data, token)=>{ | |
if (products_data === null){ | |
return loop( | |
products_data, | |
Effects.promise(()=>{ | |
let api = new ProductsApi(token); | |
return api.index() | |
.then(productsRetrieved) | |
}) | |
) | |
} | |
return products_data; | |
}, | |
// products_data from API response. | |
[productsRetrieved]: (_products_data, new_products_data)=>{ | |
// return new_products_data <- not preferred. This is a plain JS object. | |
return Immutable.fromJS(new_products_data); // <- preferred | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment