{"id":4471,"url":"https://github.com/thewei/react-native-immutable","last_synced_at":"2025-08-04T01:32:26.263Z","repository":{"id":28878170,"uuid":"32402629","full_name":"thewei/react-native-immutable","owner":"thewei","description":"**[DEPRECATED]** using immutable.js library as store with react \u0026\u0026 react-native","archived":true,"fork":true,"pushed_at":"2016-01-22T03:11:08.000Z","size":28,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-26T16:50:32.555Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"hufeng/iflux","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thewei.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":"2015-03-17T15:36:52.000Z","updated_at":"2023-02-03T10:40:42.000Z","dependencies_parsed_at":"2023-07-11T21:47:20.870Z","dependency_job_id":null,"html_url":"https://github.com/thewei/react-native-immutable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thewei/react-native-immutable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewei%2Freact-native-immutable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewei%2Freact-native-immutable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewei%2Freact-native-immutable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewei%2Freact-native-immutable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thewei","download_url":"https://codeload.github.com/thewei/react-native-immutable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewei%2Freact-native-immutable/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267447267,"owners_count":24088565,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-01-05T20:17:13.590Z","updated_at":"2025-08-04T01:32:26.033Z","avatar_url":"https://github.com/thewei.png","language":"JavaScript","readme":"# react-native-immutable\n**using immutable.js library as store with react \u0026\u0026 react-native**\n\nMore info of [immutable.js](http://facebook.github.io/immutable-js/)\n\n---\n\n\n## Installation\n\n```\n$ npm install react-native-immutable --save\n```\n\n## Useage\n\n```\nreact-native project\n   |---index.ios.js\n   |---App\n         |---Actions\n         \t   |--- mainAction.js\n         \t   |--- userAction.js\n         \t   |--- articleAction.js\n         \t   |--- ...\n         |---Stores\n         \t   |--- mainStore.js\n         \t   |--- userStore.js\n         \t   |--- articleStore.js\n         \t   |--- ...\n         |---Webapi\n         \n```\n\n### index.ios.js\n\n```javascript\n'use strict';\n\nvar React = require('react-native');\n\nvar { mixins } = require('react-native-immutable');\nvar StoreMixin = mixins.StoreMixin;\nvar appStore = require('./App/Stores/mainStore');\nvar appAction = require('./App/Actions/mainAction');\n\nvar {\n  AppRegistry,\n  StyleSheet,\n  View,\n  Text\n} = React;\n\nvar App = React.createClass({\n    mixins: [StoreMixin(appStore,\"user\",\"article\")],\n    onChangeUserName: function(){\n    \tappAction.emit('onChangeUserName', \"wilson\");\n    },\n    render: function() {\n        \n        console.log(this.state);  // when store was changed, the state will change;\n        \n        console.log(this.state.username)\n        \n        return (\n        \t\u003cView\u003e\n        \t\t\u003cText onPress={this.onChangeUserName}\u003eChange user name\u003c/Text\u003e\n        \t\u003c/View\u003e\n        )   \n    } \n});\n    \n    \nAppRegistry.registerComponent('DEMO', () =\u003e App);\n\n```\n\n\n### mainAction.js\n\n```javascript\n'use strict';\n\nvar {Action} = require('react-native-immutable');\n\n// require userAction\nrequire('./userAction')();\n\n\n// require articleAction\nrequire('./articleAction')();\n\nmodule.exports = Action;\n\n```\n\n\n### userAction.js\n\n```javascript\n'use strict';\n\nvar Immutable = require('immutable');\nvar {Action} = require('react-native-immutable');\nvar appStore = require('../Stores/mainStore');\n\n// 更新管理员\nvar userAction = function(){\n\tAction.on('onChangeUserName', function(name) {\n\t\t// study immutable.js visit http://facebook.github.io/immutable-js/\n    \tappStore.getStore(\"user\").set('name', name );\n\t});\n}\n\nmodule.exports = userAction;\n\n```\n\n### mainStore.js\n\n```javascript\n'use strict'\n\nvar Immutable = require('immutable');\nvar {Store,Action} = require('react-native-immutable');\n\nvar React = require('react-native');\n\n\n\nvar appStore = module.exports = Store({\n    user: require('./userStore'),\n    article: require('./articleStore')\n});\n\n\n// Use AsyncStorage if u what\n\nvar {\n    AsyncStorage\n} = React;\n\nvar db_name = \"app_store\";\n\nAction.on(\"_updateStore\", function(data){\n    AsyncStorage.setItem(db_name, JSON.stringify(data), function(err) {\n        if (err) {\n            console.error(\"error\")\n        }\n    });\n});\n\n//initial Data\nAsyncStorage.getItem(db_name, function(err, res) {\n    if (err) {\n        console.error(\"error\")\n    } else {\n        if( typeof res == undefined ){\n            Action.emit(\"_updateStore\",appStore.getData());\n        }else{\n            appStore = Immutable.fromJS(JSON.parse(res));\n        }\n    }\n});\n\n\n```\n\n### userStore.js\n\n```javascript\n'use strict'\n\nmodule.exports = {\n    name: ''\n}\n\n```\n\n","funding_links":[],"categories":["Components"],"sub_categories":["Utils \u0026 Infra"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthewei%2Freact-native-immutable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthewei%2Freact-native-immutable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthewei%2Freact-native-immutable/lists"}