Skip to content

Commit

Permalink
docs: changed demos in readme to be linked to the repo
Browse files Browse the repository at this point in the history
  • Loading branch information
x8lucas8x committed Sep 26, 2019
1 parent 0e8af95 commit 1a49497
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ $ yarn add react-resux
## Demos

* [__counterWithConnectResux__](https://github.com/kayak/react-resux/tree/master/examples/counterWithConnectResux)
([Demo](https://codesandbox.io/embed/react-resux-connect-resuxjs-xe2o1)):
([Demo](https://codesandbox.io/s/github/kayak/react-resux/tree/master/examples/counterWithConnectResux)):
Simple count example without hooks api.
* [__counterWithConnectResuxAndConfirmationDialog__](https://github.com/kayak/react-resux/tree/master/examples/counterWithConnectResuxAndConfirmationDialog)
([Demo](https://codesandbox.io/s/github/kayak/react-resux/tree/master/examples/counterWithConnectResuxAndConfirmationDialog)):
Simple count example without hooks api and using a confirmation dialog, prior to incrementing/decrementing.
* [__counterWithHooks__](https://github.com/kayak/react-resux/tree/master/examples/counterWithHooks)
([Demo](https://codesandbox.io/embed/react-resux-hooksjs-o1c7p)):
([Demo](https://codesandbox.io/s/github/kayak/react-resux/tree/master/examples/counterWithHooks)):
Simple count example with hooks api.
* [__rest__](https://github.com/kayak/react-resux/tree/master/examples/rest)
([Demo](https://codesandbox.io/embed/react-resux-restjs-m9zdf)):
([Demo](https://codesandbox.io/s/github/kayak/react-resux/tree/master/examples/rest)):
Multi model rest example, using subscribers and hooks api.
Data is fetched from [jsonplaceholder.typicode.com](http://jsonplaceholder.typicode.com/)

Expand Down
10 changes: 5 additions & 5 deletions docs/concepts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ export const userModel = new Model({

// Optional options
selectors: {
loadingByUser: (state, userId) => _.get(state, `users.loading[${userId}]`, true),
userById: (state, userId) => _.get(state, `users.data[${userId}]`),
loadingByUser: (state, userId) => _.get(state, `loading[${userId}]`, true),
userById: (state, userId) => _.get(state, `data[${userId}]`),
},
reducers: {
saveUser(state, { data, userId }) {
saveUser(state, {data, userId}) {
state.loading[userId] = false;
state.data[userId] = data;
},
},
effects: {
*fetchUser({ userId }, { call, put }) {
*fetchUser({userId}, {call, put}, {saveUser}) {
try {
const data = yield call(fetchApi, `http://jsonplaceholder.typicode.com/users/${userId}`);
yield put({type: "users.saveUser", data, userId});
yield put(saveUser({data, userId}));
} catch (error) {
console.log(error)
}
Expand Down

0 comments on commit 1a49497

Please sign in to comment.