{"id":27974119,"url":"https://github.com/hainv053/reduex","last_synced_at":"2025-06-25T00:06:35.857Z","repository":{"id":57350122,"uuid":"150076998","full_name":"hainv053/reduex","owner":"hainv053","description":"Management state with react context","archived":false,"fork":false,"pushed_at":"2018-09-25T03:03:18.000Z","size":14,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-09T12:26:11.866Z","etag":null,"topics":["react","react-native","reduex","redux","state-management"],"latest_commit_sha":null,"homepage":"","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/hainv053.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-09-24T08:59:51.000Z","updated_at":"2018-10-07T13:14:51.000Z","dependencies_parsed_at":"2022-09-16T21:01:55.284Z","dependency_job_id":null,"html_url":"https://github.com/hainv053/reduex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hainv053/reduex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hainv053%2Freduex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hainv053%2Freduex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hainv053%2Freduex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hainv053%2Freduex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hainv053","download_url":"https://codeload.github.com/hainv053/reduex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hainv053%2Freduex/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261777647,"owners_count":23208123,"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":["react","react-native","reduex","redux","state-management"],"created_at":"2025-05-08T00:11:26.460Z","updated_at":"2025-06-25T00:06:35.836Z","avatar_url":"https://github.com/hainv053.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# reduex\n\nState management with react context\n\n## Installation\n\n```bash\nnpm install reduex --save\n```\nor\n```bash\nyarn add reduex\n```\n\n## API\n- `\u003cProvider stores logger\u003e`: Root provider\n- `createModel({state: {}, actions: {}})`: Create store model\n- `connect`: Connect Compoment to reduex\n- `getRootState`: Get root state\n\n## Usage\n\n#### Create store\n`index.tsx`\n```ts\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport App from './App';\nimport { createModel, Provider } from 'reduex';\n\nconst app = createModel({\n    state: {\n        title: 'Hello reduex'\n    },\n    actions: {\n        changeTitle: (rootState, payload) =\u003e {\n            return {\n                title: payload.title\n            };\n        },\n        changeTitleAsync: async (rootState, payload) =\u003e {\n            \n            await new Promise(resolve =\u003e {\n                 setTimeout(resolve, 5000)\n            })\n            \n            return {\n                title: payload.title\n            };\n        }\n    }\n});\n\nconst stores = {\n    app: app\n}\n\nReactDOM.render(\n    \u003cProvider\n        logger={true}\n        stores={stores}\u003e\n        \u003cApp /\u003e\n    \u003c/Provider\u003e\n    ,\n    document.getElementById('root') as HTMLElement\n);\n\n\n```\n\n`App.tsx`\n```ts\nimport * as React from 'react';\nimport { connect, getRootState } from 'reduex';\n\nclass App extends React.Component\u003cany, any\u003e {\n\n    changeTitle = () =\u003e {\n        this.props.dispatch('app/changeTitle', {\n            title: 'Change Title'\n        });\n    };\n    \n    changeTitleAsync = () =\u003e {\n        this.props.dispatch('app/changeTitleAsync', {\n            title: 'Change Title Async'\n        });\n    };\n\n    getRootState = () =\u003e {\n        console.log(getRootState());\n    };\n\n    render() {\n        return (\n            \u003cdiv\u003e\n                \u003ch1\u003e{this.props.title}\u003c/h1\u003e  \n                \u003cbutton onClick={this.changeTitle}\u003eChange title\u003c/button\u003e\n                \u003cbutton onClick={this.getRootState}\u003eGet Root State\u003c/button\u003e\n                \u003cbutton onClick={this.changeTitleAsync}\u003e\u003c/button\u003e\n              \u003c/div\u003e\n        );\n    }\n}\n\nconst mapStateToProps = (state) =\u003e {\n    return {\n        title: state.app.title\n    };\n};\n\nexport default connect(mapStateToProps)(App);\n\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhainv053%2Freduex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhainv053%2Freduex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhainv053%2Freduex/lists"}