diff --git a/README.md b/README.md index c4cceb2..3c8a31e 100644 --- a/README.md +++ b/README.md @@ -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/) diff --git a/docs/concepts.mdx b/docs/concepts.mdx index d2c4369..acadc79 100644 --- a/docs/concepts.mdx +++ b/docs/concepts.mdx @@ -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) }