{"action":"created","issue":{"url":"https://api.github.com/repos/rt2zz/redux-persist/issues/21","labels_url":"https://api.github.com/repos/rt2zz/redux-persist/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/rt2zz/redux-persist/issues/21/comments","events_url":"https://api.github.com/repos/rt2zz/redux-persist/issues/21/events","html_url":"https://github.com/rt2zz/redux-persist/issues/21","id":112887721,"number":21,"title":"Having Rehydrated values passed in the store's initialState","user":{"login":"zalmoxisus","id":7957859,"avatar_url":"https://avatars.githubusercontent.com/u/7957859?v=3","gravatar_id":"","url":"https://api.github.com/users/zalmoxisus","html_url":"https://github.com/zalmoxisus","followers_url":"https://api.github.com/users/zalmoxisus/followers","following_url":"https://api.github.com/users/zalmoxisus/following{/other_user}","gists_url":"https://api.github.com/users/zalmoxisus/gists{/gist_id}","starred_url":"https://api.github.com/users/zalmoxisus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalmoxisus/subscriptions","organizations_url":"https://api.github.com/users/zalmoxisus/orgs","repos_url":"https://api.github.com/users/zalmoxisus/repos","events_url":"https://api.github.com/users/zalmoxisus/events{/privacy}","received_events_url":"https://api.github.com/users/zalmoxisus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-22T20:44:27Z","updated_at":"2015-10-24T06:28:45Z","closed_at":null,"body":"I still looking into it, but it would be great to achieve. Now the reducers are initiated twice: the first one with the initial value, and the second - with the rehydrated one. I tried to find some solutions, but all of them seems to be antipattern, except of this. Actually, this is the purpose of the store's initialState to pass the rehydrating state from server or localStorage.\r\nWhat do you think if we get the data from the localStorage before creating the store?"},"comment":{"url":"https://api.github.com/repos/rt2zz/redux-persist/issues/comments/150766154","html_url":"https://github.com/rt2zz/redux-persist/issues/21#issuecomment-150766154","issue_url":"https://api.github.com/repos/rt2zz/redux-persist/issues/21","id":150766154,"user":{"login":"rt2zz","id":2302315,"avatar_url":"https://avatars.githubusercontent.com/u/2302315?v=3","gravatar_id":"","url":"https://api.github.com/users/rt2zz","html_url":"https://github.com/rt2zz","followers_url":"https://api.github.com/users/rt2zz/followers","following_url":"https://api.github.com/users/rt2zz/following{/other_user}","gists_url":"https://api.github.com/users/rt2zz/gists{/gist_id}","starred_url":"https://api.github.com/users/rt2zz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rt2zz/subscriptions","organizations_url":"https://api.github.com/users/rt2zz/orgs","repos_url":"https://api.github.com/users/rt2zz/repos","events_url":"https://api.github.com/users/rt2zz/events{/privacy}","received_events_url":"https://api.github.com/users/rt2zz/received_events","type":"User","site_admin":false},"created_at":"2015-10-24T06:28:45Z","updated_at":"2015-10-24T06:28:45Z","body":"I have only partially formed thoughts on these very good points you raise:\r\n1. For specifically the sync localStorage case, we could avoid UI Flickering by calling the localStorage `getItem` syncronously invoking the localStorage callbacks syncronously (instead of using setImmediate as it currently does). I wrote this assuming async storage API's, but maybe it was a mistake to force asyncronicity with setImmediate. \r\n2. Initial state should never be stored regardless of debounce. The action buffer in autoRehydrate should ensure that rehydrate runs first before any other actions that might trigger a storage. That said I just realized action buffer was broken because of the change in compose behaivor in redux@2, I just published a fix for that in 1.2.0.\r\n\r\nI also added a debounce config parameter (in in versions >=1.1.0). From my initial test debounce: false works great.\r\n\r\nIt has occured to me that crosstab-sync implicitly depends on the fact that string equality exists in the serialized state post-rehydration. This may not be the case in `chrome.storage` since it stores unserialized objects. I have not fully thought this through, but we may need to abandon shallow merge in autoRehydrate in order to preserve post-rehydration object equality.\r\n\r\n"}}