Created
December 20, 2018 07:57
-
-
Save artalar/97b1747bd5523a4672e9a6b02b559962 to your computer and use it in GitHub Desktop.
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
| // implicit cohesions | |
| root = store({ data: { list: [] }, loading: false, error: null }) | |
| .on(req, state => ({ ...state, error: null, loading: true })) | |
| .on(res, (state, list) => ({ ...state, data: { list }, loading: false })) | |
| .on(err, (state, error) => ({ ...state, error, loading: false })); | |
| // explicit cohesions | |
| export const data = store({ list: [] }) | |
| .on(res, list => ({ list })); | |
| export const error = store(null) | |
| .on(req, () => null) | |
| .on(err, e => e); | |
| export const loading = store(false) | |
| .on(req, () => true) | |
| .on(res, () => false) | |
| .on(err, () => false); | |
| root = store({ data, error, loading }); |
artalar
commented
Dec 20, 2018
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment