{"id":20244519,"url":"https://github.com/retailmenotsandbox/redux-mount-store","last_synced_at":"2025-07-10T15:41:25.960Z","repository":{"id":73126322,"uuid":"62749329","full_name":"RetailMeNotSandbox/redux-mount-store","owner":"RetailMeNotSandbox","description":"Redux store enhancer that makes it possible to mount sub-stores","archived":false,"fork":false,"pushed_at":"2017-06-01T19:10:20.000Z","size":26,"stargazers_count":2,"open_issues_count":7,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-10T20:55:11.992Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/RetailMeNotSandbox.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-07-06T19:52:52.000Z","updated_at":"2019-11-26T15:35:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"dc35cf42-1818-4559-8333-2d6c172520fa","html_url":"https://github.com/RetailMeNotSandbox/redux-mount-store","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/RetailMeNotSandbox/redux-mount-store","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RetailMeNotSandbox%2Fredux-mount-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RetailMeNotSandbox%2Fredux-mount-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RetailMeNotSandbox%2Fredux-mount-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RetailMeNotSandbox%2Fredux-mount-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RetailMeNotSandbox","download_url":"https://codeload.github.com/RetailMeNotSandbox/redux-mount-store/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RetailMeNotSandbox%2Fredux-mount-store/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264599680,"owners_count":23635311,"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":[],"created_at":"2024-11-14T09:15:44.411Z","updated_at":"2025-07-10T15:41:25.954Z","avatar_url":"https://github.com/RetailMeNotSandbox.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redux-mount-store\n\nStore enhancer for redux adding mounting capabilities\n\n## Gist\n\nMount to a slice of the state and define data to view from that state. Receive\na store creator. That store, when created, will receive the viewed data in its\nreducer and via `getState()`.\n\n```\nconst withMounts = require('@rmn/redux-mount-store');\nconst redux = require('redux');\n\nconst mountableStore = redux.createStore(\n  (state, action) =\u003e state,\n\t{\n\t\ttodos: [\n\t\t\t{\n\t\t\t\tdescription: 'Pet a dog',\n\t\t\t\tdone: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tdescription: 'Pet a frog',\n\t\t\t\tdone: false\n\t\t\t}\n\t\t]\n\t},\n\twithMounts\n);\n\nconst createMountedStore = mountableStore.mount(\n  // the key in the mountable store where any non-virtual data will be stored\n\t'someComponent',\n  // define a mapping from the mountable store's state to the mounted store's\n  // virtual (or \"viewed\") state\n\t{\n\t\tcompletedTodos: state =\u003e state.todos.filter(todo =\u003e todo.done)\n\t}\n);\n\n// same signature as `createStore()`\nconst mountedStore = createMountedStore(\n  // this reducer receives the virtual state and its own state merged together.\n  // mutations to any virtual state will throw an error\n\t(state, action) =\u003e state,\n\n  // the mounted store's own initial state. this will be persisted to the \"real\"\n  // store.\n\t{\n\t\tisDropdownVisible: false\n\t}\n);\n```\n\nLet's call `getState()` on each store. The state that we see is the same state\nprovided to each store's reducer.\n\n```\nconsole.log(mountableStore.getState());\n\n// note that a slice of the mountable store is created for the mounted store,\n// containing its initial state. note that it does NOT contain the virtual\n// state, which is instead provided to the mounted store's reducer and when its\n// `getState()` method is called.\n// { todos:\n//    [ { description: 'Pet a dog', done: true },\n//      { description: 'Pet a frog', done: false } ],\n//   someComponent: { isDropdownVisible: false } }\n\nconsole.log(mountedStore.getState());\n\n// the mounted store sees its full state as well as its virtual/viewed state.\n// in this case, it can update `isDropdownVisible` in its own reducer and that\n// change will be visible in both stores. however, attempts to update\n// completedTodos will raise an Error\n// { isDropdownVisible: false,\n//   completedTodos: [ { description: 'Pet a dog', done: true } ] }\n```\n\n## Why?\n\nIn certain cases, this can be easier than simply mapping the store's state to\nthe shape expected by consumers. Additionally, abstracting the layer at which\nthe \"real\" store exists allows it to be plugged it any layer.\n\n## Consuming the redux-mount-store package\n\nThere are two ways of consuming `@retailmenot/redux-mount-store` within your\napplication.\n\nBy default, when you `require('@retailmenot/redux-mount-store')`. You get the redux-\nmount-store source code, which is written using ES6 features such as fat arrow\nfunctions.\n\nredux-mount-store also publishes an ES5 compatible version of itself to the\n`dist/` directory, which can be consumed by applications that are using webpack\nwithout babel by aliasing `@retailmenot/redux-mount-store` to the transpiled\ncode. In your webpack config:\n\n```javascript\nresolve: {\n    alias: {\n        '@retailmenot/redux-mount-store': path.join(\n            path.dirname(\n                require.resolve('@retailmenot/redux-mount-store')\n            ), 'dist/index.js'\n        )\n    }\n}\n```\n\nThe downside to this approach is that sourcemaps in your consuming application\nwill point to the transpiled code instead of the redux-mount-store source.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretailmenotsandbox%2Fredux-mount-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fretailmenotsandbox%2Fredux-mount-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretailmenotsandbox%2Fredux-mount-store/lists"}