{"action":"created","issue":{"url":"https://api.github.com/repos/tdeekens/flopflip/issues/369","repository_url":"https://api.github.com/repos/tdeekens/flopflip","labels_url":"https://api.github.com/repos/tdeekens/flopflip/issues/369/labels{/name}","comments_url":"https://api.github.com/repos/tdeekens/flopflip/issues/369/comments","events_url":"https://api.github.com/repos/tdeekens/flopflip/issues/369/events","html_url":"https://github.com/tdeekens/flopflip/issues/369","id":319840828,"number":369,"title":"How do I set the initial flags when using memory-adapter?","user":{"login":"janhoogeveen","id":882219,"avatar_url":"https://avatars3.githubusercontent.com/u/882219?v=4","gravatar_id":"","url":"https://api.github.com/users/janhoogeveen","html_url":"https://github.com/janhoogeveen","followers_url":"https://api.github.com/users/janhoogeveen/followers","following_url":"https://api.github.com/users/janhoogeveen/following{/other_user}","gists_url":"https://api.github.com/users/janhoogeveen/gists{/gist_id}","starred_url":"https://api.github.com/users/janhoogeveen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janhoogeveen/subscriptions","organizations_url":"https://api.github.com/users/janhoogeveen/orgs","repos_url":"https://api.github.com/users/janhoogeveen/repos","events_url":"https://api.github.com/users/janhoogeveen/events{/privacy}","received_events_url":"https://api.github.com/users/janhoogeveen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-03T09:08:52Z","updated_at":"2018-05-03T09:27:57Z","closed_at":null,"author_association":"NONE","body":"I've got memory adapter working right now with Redux. However, it looks to me like the only way to add flags to the store is by using `updateFlags({ fooFeature: true });`.\r\n\r\nIs there a way where I can preconfigure all default flags? I want to do an API call to retrieve new flags and update those manually whenever I feel like they need changing, but that doesn't mean I want to block components from rendering while the store is not populated yet.\r\n\r\nRelevant code:\r\n\r\n**Redux store**\r\n\r\n```js\r\nimport { createStore, applyMiddleware, compose } from 'redux';\r\nimport { createFlopFlipEnhancer } from '@flopflip/react-redux';\r\nimport adapter from '@flopflip/memory-adapter';\r\nimport rootReducer from './rootReducer';\r\n\r\nconst enhancer = compose(\r\n  ...\r\n  createFlopFlipEnhancer(adapter),\r\n  ...\r\n);\r\n\r\nexport default function configureStore(initialState = {}) {\r\n  const store = createStore(rootReducer, initialState, enhancer);\r\n  return store;\r\n}\r\n```\r\n\r\n**Reducer setup**\r\n```js\r\nimport { combineReducers } from 'redux';\r\nimport { flopflipReducer, FLOPFLIP_STATE_SLICE } from '@flopflip/react-redux';\r\nimport utility from './reducers/utility';\r\n\r\nconst rootReducer = combineReducers({\r\n  [FLOPFLIP_STATE_SLICE]: flopflipReducer,\r\n  utility,\r\n});\r\n\r\nexport default rootReducer;\r\n```\r\n\r\nWhat I came up with on my own:\r\n\r\n1. Using [createStore's preloadedState argument](https://redux.js.org/api-reference/createstore#arguments). This works, but it feels very wrong. This should be reserved for sending state from the server to client for state hydration. Not like a place to set default flags for my reducers.\r\n\r\n2. Not using flopflopReducer in my combineReducer method. I don't think this will work, and you're probably using this method for a good reason.\r\n\r\n3. Using updateFlags({}) on initial app load, before rendering the UI. This probably works, but it feels like a hack and like it would trigger new renders without any good reason. "},"comment":{"url":"https://api.github.com/repos/tdeekens/flopflip/issues/comments/386238683","html_url":"https://github.com/tdeekens/flopflip/issues/369#issuecomment-386238683","issue_url":"https://api.github.com/repos/tdeekens/flopflip/issues/369","id":386238683,"user":{"login":"janhoogeveen","id":882219,"avatar_url":"https://avatars3.githubusercontent.com/u/882219?v=4","gravatar_id":"","url":"https://api.github.com/users/janhoogeveen","html_url":"https://github.com/janhoogeveen","followers_url":"https://api.github.com/users/janhoogeveen/followers","following_url":"https://api.github.com/users/janhoogeveen/following{/other_user}","gists_url":"https://api.github.com/users/janhoogeveen/gists{/gist_id}","starred_url":"https://api.github.com/users/janhoogeveen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janhoogeveen/subscriptions","organizations_url":"https://api.github.com/users/janhoogeveen/orgs","repos_url":"https://api.github.com/users/janhoogeveen/repos","events_url":"https://api.github.com/users/janhoogeveen/events{/privacy}","received_events_url":"https://api.github.com/users/janhoogeveen/received_events","type":"User","site_admin":false},"created_at":"2018-05-03T09:27:57Z","updated_at":"2018-05-03T09:27:57Z","author_association":"NONE","body":"I think the flopflipReducer method from `@flopflip/react-redux` could accept an _initialFlags_ argument, which would solve this whole issue?"}}
{"actor":{"display_login":"janhoogeveen"}}