{"id":19345582,"url":"https://github.com/future-team/gfs-react-redux-twoway-binding","last_synced_at":"2026-05-12T23:06:08.852Z","repository":{"id":57250765,"uuid":"76619023","full_name":"future-team/gfs-react-redux-twoway-binding","owner":"future-team","description":"react-redux数据双向绑定组件","archived":false,"fork":false,"pushed_at":"2017-01-04T03:22:33.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-06T17:36:56.389Z","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/future-team.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":"2016-12-16T03:46:33.000Z","updated_at":"2017-01-11T02:01:16.000Z","dependencies_parsed_at":"2022-08-24T16:52:06.724Z","dependency_job_id":null,"html_url":"https://github.com/future-team/gfs-react-redux-twoway-binding","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-team%2Fgfs-react-redux-twoway-binding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-team%2Fgfs-react-redux-twoway-binding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-team%2Fgfs-react-redux-twoway-binding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-team%2Fgfs-react-redux-twoway-binding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/future-team","download_url":"https://codeload.github.com/future-team/gfs-react-redux-twoway-binding/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240452202,"owners_count":19803584,"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-10T04:07:09.928Z","updated_at":"2026-05-12T23:06:08.827Z","avatar_url":"https://github.com/future-team.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gfs-react-redux-twoway-binding\n\n数据双向绑定，在React Component中直接改变redux store中数据对象值，达到重新渲染页面的目的，减少编写更多的action；使用时请注意store数据对象必须是immutable类型且次组件是一个装饰类（decorator）\n\n## 安装\n\n```bash\n\n\tnpm install gfs-react-redux-twoway-binding\n```\n\n## 依赖\n\n* `immutable`\n\n## 使用\t\t\t\n\n### 1. createReducer\n\n创建一个redux store；\n\n```js\n\n\timport { createReducer } from 'gfs-react-redux-twoway-binding';\n    import Immutable from 'immutable';\n\n    const initialState = Immutable.fromJS({\n        name:'init'\n    });\n\n    export const test = createReducer('test',initialState, {\n        ['QUERY']: (data, action) =\u003e {\n            return data.merge(Immutable.fromJS(action.data));\n        }\n    });\n```\n\n### 2. setStore\n\n组件与具体的store建立关系；\n\n```js\n\n\timport {bindingMixin} from 'gfs-react-redux-twoway-binding';\n\n\t//用次组件装饰下面的类\n    @bindingMixin\n    export default class TestWebContainer extends Component {\n        constructor(props) {\n            super(props);\n\n            //关联store\n            this.setBinding('test');\n\n        }\n    }\n```\n\n### 3. binding\n\n数据双向绑定，使用`this.binding`方法与具体字段绑定，表单元素发生改变时将直接会改变store中的值；\n\n```js\n\n\trender() {\n\t\treturn (\n\t\t\t\u003cdiv\u003e\n\t\t\t\t\u003cinput type=\"text\"  valueLink={this.binding('name')  } /\u003e\n\t\t\t\t{this.props.test.get('name') }\n\t\t\t\u003c/div\u003e\n\t\t);\n\t}\n```\n\n## Manual Change Functions\n\n帮助用户快速根据reducer路径更改store值，避免写更多的action。\n\n* 手动根据路径改变reducer的值:\n\n```js\n\n\tthis.manualChange('name', 'john');\n\n\tthis.manualChange('name', function(age){\n        return ++age;\n    });\n```\n\n## Command\n\n```\n\t#测试\t\n\tnpm run test\t\n\t#打包\t\n\tnpm run build\t\n\t#例子演示\t\n\tnpm start\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuture-team%2Fgfs-react-redux-twoway-binding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuture-team%2Fgfs-react-redux-twoway-binding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuture-team%2Fgfs-react-redux-twoway-binding/lists"}