{"id":15689809,"url":"https://github.com/defint/redux-actions-async","last_synced_at":"2025-05-07T23:08:44.981Z","repository":{"id":57350148,"uuid":"127468724","full_name":"defint/redux-actions-async","owner":"defint","description":"A small library that facilitates the development of asynchronous actions in the redux ecosystem. Without copy-paste code and without headache.","archived":false,"fork":false,"pushed_at":"2018-06-28T06:50:59.000Z","size":36,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T23:08:38.418Z","etag":null,"topics":["actions","normalizr","react","redux","reselect"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/redux-actions-async","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/defint.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-30T20:08:38.000Z","updated_at":"2024-02-06T13:50:31.000Z","dependencies_parsed_at":"2022-09-16T21:02:03.324Z","dependency_job_id":null,"html_url":"https://github.com/defint/redux-actions-async","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defint%2Fredux-actions-async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defint%2Fredux-actions-async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defint%2Fredux-actions-async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defint%2Fredux-actions-async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/defint","download_url":"https://codeload.github.com/defint/redux-actions-async/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252968118,"owners_count":21833252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","normalizr","react","redux","reselect"],"created_at":"2024-10-03T18:04:36.745Z","updated_at":"2025-05-07T23:08:44.952Z","avatar_url":"https://github.com/defint.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Redux async actions\n=========\n\nA small library that facilitates the development of asynchronous actions in the redux ecosystem. Without copy-paste code and without headache.\n\n\n## Installation\n\n* npm: \n  `npm install --save redux-actions-async`\n  \n* yarn:\n   `yarn add redux-actions-async`\n\n## Basic usage\n\n1) Create your async function, for example to make request with axios:\n\n    ```\n    import axios from 'axios';\n\n    export const fetchPlanet = () =\u003e\n      axios.request({\n        url: 'https://api.nasa.gov/planetary/apod',\n        method: 'get',\n      });\n    ``` \n    \n2) Create the first async action creator:\n\n    ```\n    import { createAsyncAction } from 'redux-actions-async';\n        \n    export const nasaFetchPlanet = createAsyncAction('NASA_DATA_FETCH', fetchPlanet);\n    ```\n    \n3) Create async reducer:\n\n    ```\n    import { handleAsyncActions } from 'redux-actions-async';\n    \n    export default handleAsyncActions(nasaFetchPlanet);\n    ```\n    \n4) Create selectors:\n\n    ```\n    import { createAsyncSelector, createLoadingSelector } from 'redux-actions-async';\n    \n    const _selector = state =\u003e state.nasa;\n    export const dataSelector = createAsyncSelector(_selector);\n    export const loadingSelector = createLoadingSelector(_selector);\n    ``` \n\n5) Using in container:\n\n    ```\n    import { connect } from 'react-redux';\n    import * as actionCreators from '../actionCreators';\n    import * as selectors from '../selectors';\n    \n    const mapStateToProps = state =\u003e ({\n      loading: selectors.loadingSelector(state),\n      planet: selectors.dataSelector(state),\n    });\n    \n    const mapDispatchToProps = {\n      nasaFetchPlanet: actionCreators.nasaFetchPlanet,\n    };\n    \n    export default connect(mapStateToProps, mapDispatchToProps)(App);\n    \n    ```\n\n## Basic usage with nested reducers\n```\n    import { handleAsyncActions } from 'redux-actions-async';\n    import { combineReducers } from 'redux';\n    \n    export default combineReducers({\n      main: handleAsyncActions(nasaFetchPlanet),\n      another: handleAsyncActions(nasaFetchAnotherPlanet),\n    });\n```\n\n## Usage with normalizr\n\n\n1) Create function to make request (same as basic usage):\n\n    ```\n    import axios from 'axios';\n\n    export const fetchCuriosityPhotos = () =\u003e\n      axios.request({\n        url: 'https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/',\n        method: 'get',\n      });\n    ``` \n    \n2) Define schema:\n\n    ```\n    import { schema } from 'normalizr';\n    \n    const photo = new schema.Entity('photo');\n    \n    export default photo;\n    \n    ```\n    \n3) Create the first async action creator:\n\n    ```\n    import { createAsyncAction } from 'redux-actions-async';\n    import photo from '../schemas/photo';\n        \n    export const nasaFetchCuriosity = createAsyncAction(\n      'NASA_CURIOSITY_FETCH',\n      fetchCuriosityPhotos,\n      data =\u003e normalize(data.photos, [photo])\n    );    \n    ```\n    \n4) Create async reducer (same as basic usage):\n\n    ```\n    import { handleAsyncActions } from 'redux-actions-async';\n    \n    export default handleAsyncActions(nasaFetchCuriosity);\n    ```\n   \n5)  Create selectors:\n    \n    ```\n    import { createAsyncSelector, createLoadingSelector } from 'redux-actions-async';\n    import photo from '../schemas/photo';\n    \n    const _selector = state =\u003e state.nasaCuriosity;\n    export const dataSelector = createAsyncSelector(_selector, [photo]);\n    export const loadingSelector = createLoadingSelector(_selector);\n    ``` \n    \n6) Using in container:\n\n    ```\n    import { connect } from 'react-redux';\n    import * as actionCreators from '../actionCreators';\n    import * as selectors from '../selectors';\n    \n    const mapStateToProps = state =\u003e ({\n      loading: selectors.loadingSelector(state),\n      curiosity: selectors.dataSelector(state),\n    });\n    \n    const mapDispatchToProps = {\n      nasaFetchCuriosity: actionCreators.nasaFetchCuriosity,\n    };\n    \n    export default connect(mapStateToProps, mapDispatchToProps)(App);\n    \n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefint%2Fredux-actions-async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefint%2Fredux-actions-async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefint%2Fredux-actions-async/lists"}