{"_id":"@alexghenderson/redux-modules","_rev":"7-55c94dc6c08fe9441771876d63113cfd","name":"@alexghenderson/redux-modules","dist-tags":{"latest":"1.2.1"},"versions":{"1.0.0":{"name":"@alexghenderson/redux-modules","version":"1.0.0","description":"Redux minus a lot of boilerplate","main":"dist/index.js","scripts":{"build":"rm -rf dist && babel src -d dist ","prepare":"npm run build"},"author":"","license":"ISC","devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-object-rest-spread":"^6.26.0"},"peerDependencies":{"react-redux":"^5.0.6"},"dependencies":{"immer":"^1.0.1"},"gitHead":"1754936a8b3c7bcf9e3cb965b7055fecf348684f","_id":"@alexghenderson/redux-modules@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.1.1","_npmUser":{"name":"alexghenderson","email":"alex.g.henderson@gmail.com"},"dist":{"integrity":"sha512-a87kJ59huDHlJM91msLhRT6vLMoQCteQWfhP/2tzb3Aimc1bt/KLPp+OauoqufDEkdRghEL1f7TUUDjyvEDiKw==","shasum":"c17b4894726d02a617196a3740fce265396b6f9a","tarball":"https://registry.npmjs.org/@alexghenderson/redux-modules/-/redux-modules-1.0.0.tgz","fileCount":4,"unpackedSize":7956,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCDnTEjbqPd5rLb6TNYhzmqGG5Lw87cM4/OzkyhJxA6+gIgGXkLg7BFIyljmc06v8A1Wldc0khbqGcb5k6ptNkh8+8="}]},"maintainers":[{"name":"alexghenderson","email":"alex.g.henderson@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redux-modules_1.0.0_1517983959511_0.3495724826335964"},"_hasShrinkwrap":false},"1.0.1":{"name":"@alexghenderson/redux-modules","version":"1.0.1","description":"Redux minus a lot of boilerplate","main":"dist/index.js","scripts":{"build":"rm -rf dist && babel src -d dist ","prepare":"npm run build"},"author":"","license":"ISC","devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-object-rest-spread":"^6.26.0"},"peerDependencies":{"react-redux":"^5.0.6"},"dependencies":{"immer":"^1.0.1"},"gitHead":"cfedab3e45b9eb8c9d8fcc44f6d42763937447da","_id":"@alexghenderson/redux-modules@1.0.1","_npmVersion":"5.6.0","_nodeVersion":"8.1.1","_npmUser":{"name":"alexghenderson","email":"alex.g.henderson@gmail.com"},"dist":{"integrity":"sha512-ezSqUqTimen46CGBuERWmaDJ8dKBAgV1vrcvKh5N1u5S1dB5h5xWH1/47FxpO+2fNGR+Y2eBX201ApXdUORUgQ==","shasum":"e755fe977e82a688f6fb95a4db77a49fbd5fca36","tarball":"https://registry.npmjs.org/@alexghenderson/redux-modules/-/redux-modules-1.0.1.tgz","fileCount":4,"unpackedSize":7974,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBxkqEyLGp2EDkLBiYkwmmF2T9PZPYUwjXcVmPSczXQQAiBPefgxYwZ9qqEm+HYcolmm//Cg4MEnsfJjZnm1bDwbaA=="}]},"maintainers":[{"name":"alexghenderson","email":"alex.g.henderson@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redux-modules_1.0.1_1517984081181_0.6361909922591875"},"_hasShrinkwrap":false},"1.1.0":{"name":"@alexghenderson/redux-modules","version":"1.1.0","description":"Redux minus a lot of boilerplate","main":"dist/index.js","scripts":{"build":"rm -rf dist && babel src -d dist ","prepare":"npm run build"},"author":"","license":"ISC","devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-object-rest-spread":"^6.26.0"},"peerDependencies":{"react-redux":"^5.0.6"},"dependencies":{"immer":"^1.0.1"},"gitHead":"7be85ad2b4030d012d52bd3a4c951c4453be0507","_id":"@alexghenderson/redux-modules@1.1.0","_npmVersion":"5.6.0","_nodeVersion":"9.3.0","_npmUser":{"name":"alexghenderson","email":"alex.g.henderson@gmail.com"},"dist":{"integrity":"sha512-2AXTB2oJ1F5cTgodLB3eSj7XPHObEHFOzkT6QvzUEerWeZAHbJJtwOpdgrZdJKQ2lxBZCgi4GKe4K/5oT2TOOg==","shasum":"6dc226996e0d53422fb26220e10052fcf498a447","tarball":"https://registry.npmjs.org/@alexghenderson/redux-modules/-/redux-modules-1.1.0.tgz","fileCount":6,"unpackedSize":9924,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA7aI3E2EN3EraOase09MBQXy+kAffjbjHPGkLZ9s+uoAiEAgHUsJKgXXiFYDbJDkjerto60ALeRXp0sOl/fPHsRhdg="}]},"maintainers":[{"name":"alexghenderson","email":"alex.g.henderson@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redux-modules_1.1.0_1518031487129_0.03623867234683309"},"_hasShrinkwrap":false},"1.1.1":{"name":"@alexghenderson/redux-modules","version":"1.1.1","description":"Redux minus a lot of boilerplate","main":"dist/index.js","scripts":{"build":"rm -rf dist && babel src -d dist ","prepare":"npm run build"},"author":"","license":"ISC","devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-object-rest-spread":"^6.26.0"},"peerDependencies":{"react-redux":"^5.0.6"},"dependencies":{"immer":"^1.0.1"},"gitHead":"3b5f670610d1e54652cca1c4f231daf04bb8ede4","_id":"@alexghenderson/redux-modules@1.1.1","_npmVersion":"5.6.0","_nodeVersion":"9.3.0","_npmUser":{"name":"alexghenderson","email":"alex.g.henderson@gmail.com"},"dist":{"integrity":"sha512-IA0EjSchJEuoEjp7qzf9deDJ4PVVnhoy/yH/+11IXLEO+66t2OJLPHLPg1GFVrZ1OHWqGngQTuskCGspuooHIA==","shasum":"e412c2806d31cae30b8f9f6fcb33158b55478a88","tarball":"https://registry.npmjs.org/@alexghenderson/redux-modules/-/redux-modules-1.1.1.tgz","fileCount":6,"unpackedSize":9924,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCvX62y8PQXT7mL3iKJ1ffli4Xvca/exmU5lcVGKr9bBQIgDi3MsTdAQVjNu5BkcBodqKSIQOkmCq4uuU7RoK7JmRA="}]},"maintainers":[{"name":"alexghenderson","email":"alex.g.henderson@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redux-modules_1.1.1_1518031695785_0.9628762684623564"},"_hasShrinkwrap":false},"1.2.0":{"name":"@alexghenderson/redux-modules","version":"1.2.0","description":"Redux minus a lot of boilerplate","main":"dist/index.js","scripts":{"build":"rm -rf dist && babel src -d dist ","prepare":"npm run build"},"author":"","license":"ISC","devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-env":"^1.6.1"},"peerDependencies":{"react-redux":"^5.0.6"},"dependencies":{"immer":"^1.0.1"},"gitHead":"626fc1fe5bb21931ff9dfb9aabd2f2525da66dca","_id":"@alexghenderson/redux-modules@1.2.0","_npmVersion":"5.6.0","_nodeVersion":"9.3.0","_npmUser":{"name":"alexghenderson","email":"alex.g.henderson@gmail.com"},"dist":{"integrity":"sha512-h9+/lV+j46mQkkOisvoec2y4dR6TYE8cYjwk5HTjWu6afhWLyxnxm6LD3ianraFooVXMho2HQlekeTnzcxUxVg==","shasum":"ad77ee267aaa58453086d6ecab9e1cb13f51c262","tarball":"https://registry.npmjs.org/@alexghenderson/redux-modules/-/redux-modules-1.2.0.tgz","fileCount":6,"unpackedSize":13700,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDcFpeXtv05c2G2vSy/qDzaSqUbC0lWHD/OtLjNk67vXAIgXBTzGemH7g0QZugbgvrtSjdlb221sYsb2Y0rtWi3PpE="}]},"maintainers":[{"name":"alexghenderson","email":"alex.g.henderson@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redux-modules_1.2.0_1518063803330_0.36189433364627654"},"_hasShrinkwrap":false},"1.2.1":{"name":"@alexghenderson/redux-modules","version":"1.2.1","description":"Redux minus a lot of boilerplate","main":"dist/index.js","scripts":{"build":"rm -rf dist && babel src -d dist ","prepare":"npm run build"},"author":"","license":"ISC","devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-env":"^1.6.1"},"peerDependencies":{"react-redux":"^5.0.6"},"dependencies":{"babel-polyfill":"^6.26.0","immer":"^1.0.1"},"gitHead":"4ccb4e74f873e72e2b292faf925cf837c7325ea1","_id":"@alexghenderson/redux-modules@1.2.1","_npmVersion":"5.6.0","_nodeVersion":"9.3.0","_npmUser":{"name":"alexghenderson","email":"alex.g.henderson@gmail.com"},"dist":{"integrity":"sha512-700+YpsBabYIZ9gCwR47CIW8ztq5S0rjAbol3ZhPyLa8UqoPvJ8gyRF3s3kTborSqfxgpkgqN3hMgcm+Gl6LWA==","shasum":"3067a611ca13772f7540efa258270bef781e6472","tarball":"https://registry.npmjs.org/@alexghenderson/redux-modules/-/redux-modules-1.2.1.tgz","fileCount":6,"unpackedSize":13733,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQClpcytYVzXm2/DkQLW3a6SHXetPEvkg9DsNzPJamhKHQIhAPDV2bAeFGI01id+T5ZQmbkZlFNNVw9+OcYl66ZVcd5B"}]},"maintainers":[{"name":"alexghenderson","email":"alex.g.henderson@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redux-modules_1.2.1_1518064155412_0.30599209695256113"},"_hasShrinkwrap":false}},"time":{"created":"2018-02-07T06:12:39.511Z","1.0.0":"2018-02-07T06:12:39.617Z","modified":"2022-04-04T12:40:05.174Z","1.0.1":"2018-02-07T06:14:41.235Z","1.1.0":"2018-02-07T19:24:47.194Z","1.1.1":"2018-02-07T19:28:15.896Z","1.2.0":"2018-02-08T04:23:24.021Z","1.2.1":"2018-02-08T04:29:16.104Z"},"maintainers":[{"name":"alexghenderson","email":"alex.g.henderson@gmail.com"}],"description":"Redux minus a lot of boilerplate","license":"ISC","readme":"## Overview\nHeavily inspired by redux-box, some of the ideas and methodology is shamelessly ripped from it. However, redux-modules allows easier integration into existing code. Unlike redux-box, it does not require a custom store creator, or any special code. It simply generates a map of reducers, sagas, and tools for connecting the modules to components.\n\n## Installation\nInstall react, redux, and react-redux:\n```bash\nnpm install --save react redux react-redux\n```\n\nInstall redux-modules:\n```bash\nnpm install --save @alexghenderson/redux-modules\n```\n\n## Usage\nredux-modules provides a method of declaring redux modules, allowing you to easily integrate them into your existing store and mapping them to your component, either through higher order components or child functions\n\n`src/store/user/index.js`\n```js\nimport {createTypes, createAction, createContainer} from '@alexghenderson/redux-modules';\n\nconst name = 'users'\n\nconst types = createTypes(name)({\n    ADD_USER: 'ADD_USER'\n});\n\nconst initial = {users: []};\n\nconst mutations = {\n    [types.ADD_USER]: (state, {payload}) => {state.users.push(payload)},\n};\n\nconst actions = {\n    addUser: createAction(types.ADD_USER),\n};\n\n/* Optional: */\nconst sagas = {\n  [types.ADD_USER]: function* (action) {\n    yield call(window.alert, `Added user ${action.payload.name}`);\n  },\n};\n\nexport const module = {\n    name,\n    initial,\n    mutations,\n    actions,\n};\n\nexport default createContainer(module);\n```\n`src/store/reducers.js`\n```js\nimport {module as userModule} from './user';\n\nconst moduleReducers = getReducers([\n    userModule,\n]);\n\nconst reducers = {\n    //other reducers,\n    ...moduleReducers,\n};\n\nexport default reducers;\n```\n\n`src/store/sagas.js`\n```js\nimport {getSagas, createRootSaga} from '@alexghenderson/redux-modules/saga';\nimport {module as userModule} from './user';\nconst moduleSagas = getSagas([usersModule]);\n\nconst sagas = [\n    ...moduleSagas,\n    //Any other sagas\n];\n\nexport default createRootSaga(sagas);\n```\n\n`src/store/index.js`\n```js\nimport {createStore} from 'redux';\nimport createSagaMiddleware from 'redux-saga'; //optional\n\nimport saga from './sagas';\nimport reducers from './reducers';\n\nexport default () => {\n  const sagaMiddleware = createSagaMiddleware(); //optional\n  const store = createStore(reducers, sagaMiddleware/* optional */);\n  sagaMiddleware.run(saga); //optional\n\n  return store;\n};\n```\n\nAny component file (using connect)\n```js\nimport {connect} from '@alexghenderson/redux-modules';\nimport {module as userModule} from 'src/store/user';\n\n@connect({\n  user: userModule,\n})\nclass SomeComponent extends React.Component {\n  render() {\n    const {user} = this.props;\n    const {users, addUser} = user;\n    return (\n      //component code\n    )\n  }\n}\n```\n\nor, using child functions\n```js\nimport UserModule from 'src/store/user';\n\nconst SomeComponent = () => (\n  <UserModule>\n    {({users, addUser})=>(\n      <div>\n        {users.map((user)=>(\n          <span>{user.name}</span>\n        ))}\n        <button onClick={()=>(addUser({name: 'Jimmy'}))}>\n      </div>\n    )}\n  </UserModule>\n)\n```\n\n## Module Definitions\nModules are defined as an object with the following keys:\n* `name` The name of the module\n* `initial` The initial state of the module. Note: redux-modules only supports objects for module states.\n* `mutations` The mutations that form the reducer. An object with the action types as the keys, and functions that transform the state as values. Note: redux-modules uses immer to maintain immutability. You can mutate the state here, it is actually a proxy so the real state isn't modified.\n* `actions` The actions for the module. An object with the action names for keys and the action creators for the values. Redux-modules provides a `createAction` utility to make defining the actions a bit cleaner.\n* `sagas` Sagas for the module. An object with the action type for the key and the generator function for the values. Optional.\n\n## Utility Functions\n* `createTypes(moduleName)(typeMap)` Creates a type map for namespacing types. Not required, but recommended to prevent type name collisions.\n* `createAction(actionType, payloadCreator)` Creates an action creator for the specified type. The payload is generated by passing the parameters to the payloadCreator function.\n* `getReducers(moduleList)` Creates an object with the module names for keys and the reducer functions for values. Used to generate reducers that can be passed to combineReducers.\n* `createContainer(module)` Creates a connected function-as-a-child component for a specified module.\n* `connect(moduleMap)` Like react-redux connect, except takes an object with the names of the props for keys, and the modules for values. Will intelligently map the actions and state to the prop names provided. Used for creating higher-order-components.\n\n## Saga Utility function\nNote: These are exports from `@alexghenderson/redux-modules/saga`\n* `getSagas(moduleList)` Returns an array of sagas for each module.\n* `createRootSaga(sagasList)` Creates a root saga to pass to sagaMiddleware.run(). Takes an array of sagas as a parameter (which can be created from getSagas).","readmeFilename":"README.md"}