{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/immutable-js/issues/530","labels_url":"https://api.github.com/repos/facebook/immutable-js/issues/530/labels{/name}","comments_url":"https://api.github.com/repos/facebook/immutable-js/issues/530/comments","events_url":"https://api.github.com/repos/facebook/immutable-js/issues/530/events","html_url":"https://github.com/facebook/immutable-js/issues/530","id":92607839,"number":530,"title":"Introducing immutablejs in an existing application","user":{"login":"mrgreen7","id":7460509,"avatar_url":"https://avatars.githubusercontent.com/u/7460509?v=3","gravatar_id":"","url":"https://api.github.com/users/mrgreen7","html_url":"https://github.com/mrgreen7","followers_url":"https://api.github.com/users/mrgreen7/followers","following_url":"https://api.github.com/users/mrgreen7/following{/other_user}","gists_url":"https://api.github.com/users/mrgreen7/gists{/gist_id}","starred_url":"https://api.github.com/users/mrgreen7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrgreen7/subscriptions","organizations_url":"https://api.github.com/users/mrgreen7/orgs","repos_url":"https://api.github.com/users/mrgreen7/repos","events_url":"https://api.github.com/users/mrgreen7/events{/privacy}","received_events_url":"https://api.github.com/users/mrgreen7/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-02T10:46:36Z","updated_at":"2015-07-14T11:34:22Z","closed_at":null,"body":"Scenario: Introduce immutable js into an existing application. Data from the server is received, should be rendered immutable and then be used throughout the app. Using fromJS() on the received data is conceptually fine, however the application contains a lot of code accessing the received data via '.' for objects and [] for arrays. Thus a large refactoring would be required, introducing .get() calls everywhere.\r\n\r\nIs there a simple way that would not require to refactor all the read accesses?"},"comment":{"url":"https://api.github.com/repos/facebook/immutable-js/issues/comments/121210454","html_url":"https://github.com/facebook/immutable-js/issues/530#issuecomment-121210454","issue_url":"https://api.github.com/repos/facebook/immutable-js/issues/530","id":121210454,"user":{"login":"phillipCouto","id":382715,"avatar_url":"https://avatars.githubusercontent.com/u/382715?v=3","gravatar_id":"","url":"https://api.github.com/users/phillipCouto","html_url":"https://github.com/phillipCouto","followers_url":"https://api.github.com/users/phillipCouto/followers","following_url":"https://api.github.com/users/phillipCouto/following{/other_user}","gists_url":"https://api.github.com/users/phillipCouto/gists{/gist_id}","starred_url":"https://api.github.com/users/phillipCouto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phillipCouto/subscriptions","organizations_url":"https://api.github.com/users/phillipCouto/orgs","repos_url":"https://api.github.com/users/phillipCouto/repos","events_url":"https://api.github.com/users/phillipCouto/events{/privacy}","received_events_url":"https://api.github.com/users/phillipCouto/received_events","type":"User","site_admin":false},"created_at":"2015-07-14T11:34:22Z","updated_at":"2015-07-14T11:34:22Z","body":"My personal suggestion would be to have a local variable representing the data at the top of a function. There you can use the .toObject, .toArray, .toJS methods to maintain the '.' access pattern but guarantee that your code in the function can't mutate the variable outside of the local instance.\r\n\r\nExample:\r\n```js\r\nfunction processData() {\r\n   var result = restData.toObject();\r\n\r\n   console.log(result.ID);\r\n}\r\n```\r\n\r\nThis does not prevent your code within the function mutating the local result variable but at least the mutation is contained and won't pollute the external reference."}}