{"action":"created","issue":{"url":"https://api.github.com/repos/infinitered/ignite/issues/500","repository_url":"https://api.github.com/repos/infinitered/ignite","labels_url":"https://api.github.com/repos/infinitered/ignite/issues/500/labels{/name}","comments_url":"https://api.github.com/repos/infinitered/ignite/issues/500/comments","events_url":"https://api.github.com/repos/infinitered/ignite/issues/500/events","html_url":"https://github.com/infinitered/ignite/issues/500","id":190847289,"number":500,"title":"Non pure functions in LoginRedux.js","user":{"login":"joshg111","id":3508674,"avatar_url":"https://avatars1.githubusercontent.com/u/3508674?v=4","gravatar_id":"","url":"https://api.github.com/users/joshg111","html_url":"https://github.com/joshg111","followers_url":"https://api.github.com/users/joshg111/followers","following_url":"https://api.github.com/users/joshg111/following{/other_user}","gists_url":"https://api.github.com/users/joshg111/gists{/gist_id}","starred_url":"https://api.github.com/users/joshg111/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshg111/subscriptions","organizations_url":"https://api.github.com/users/joshg111/orgs","repos_url":"https://api.github.com/users/joshg111/repos","events_url":"https://api.github.com/users/joshg111/events{/privacy}","received_events_url":"https://api.github.com/users/joshg111/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-21T21:57:27Z","updated_at":"2017-11-05T13:16:44Z","closed_at":"2016-11-22T04:34:47Z","author_association":"NONE","body":"I'm curious why the reducers in LoginRedux.js are not pure. It seems they use state.merge(..) which I think will change the original state object. Redux implementations seem to always stress having reducers be pure functions, even in the redux sauce use cases they use pure functions. I'm not sure the side effects of not using pure functions though so maybe it's not such a big deal. Example of what I'm referencing below. \r\n\r\n```javascript\r\n// @flow\r\n\r\nimport { createReducer, createActions } from 'reduxsauce'\r\nimport Immutable from 'seamless-immutable'\r\n\r\n/* ------------- Types and Action Creators ------------- */\r\n\r\nconst { Types, Creators } = createActions({\r\n  loginRequest: ['username', 'password'],\r\n  loginSuccess: ['username'],\r\n  loginFailure: ['error'],\r\n  logout: null\r\n})\r\n\r\nexport const LoginTypes = Types\r\nexport default Creators\r\n\r\n/* ------------- Initial State ------------- */\r\n\r\nexport const INITIAL_STATE = Immutable({\r\n  username: null,\r\n  error: null,\r\n  fetching: false\r\n})\r\n\r\n/* ------------- Reducers ------------- */\r\n// I'm talking about the following functions which use state.merge(..). \r\n// My understanding is that merge will change the original state object.\r\n\r\n// we're attempting to login\r\nexport const request = (state: Object) => state.merge({ fetching: true })\r\n\r\n// we've successfully logged in\r\nexport const success = (state: Object, { username }: Object) =>\r\n  state.merge({ fetching: false, error: null, username })\r\n\r\n// we've had a problem logging in\r\nexport const failure = (state: Object, { error }: Object) =>\r\n  state.merge({ fetching: false, error })\r\n\r\n// we've logged out\r\nexport const logout = (state: Object) => INITIAL_STATE\r\n\r\n/* ------------- Hookup Reducers To Types ------------- */\r\n\r\nexport const reducer = createReducer(INITIAL_STATE, {\r\n  [Types.LOGIN_REQUEST]: request,\r\n  [Types.LOGIN_SUCCESS]: success,\r\n  [Types.LOGIN_FAILURE]: failure,\r\n  [Types.LOGOUT]: logout\r\n})\r\n\r\n/* ------------- Selectors ------------- */\r\n\r\n// Is the current user logged in?\r\nexport const isLoggedIn = (loginState: Object) => loginState.username !== null\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/infinitered/ignite/issues/comments/341972445","html_url":"https://github.com/infinitered/ignite/issues/500#issuecomment-341972445","issue_url":"https://api.github.com/repos/infinitered/ignite/issues/500","id":341972445,"user":{"login":"jorgutdev","id":30719489,"avatar_url":"https://avatars2.githubusercontent.com/u/30719489?v=4","gravatar_id":"","url":"https://api.github.com/users/jorgutdev","html_url":"https://github.com/jorgutdev","followers_url":"https://api.github.com/users/jorgutdev/followers","following_url":"https://api.github.com/users/jorgutdev/following{/other_user}","gists_url":"https://api.github.com/users/jorgutdev/gists{/gist_id}","starred_url":"https://api.github.com/users/jorgutdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jorgutdev/subscriptions","organizations_url":"https://api.github.com/users/jorgutdev/orgs","repos_url":"https://api.github.com/users/jorgutdev/repos","events_url":"https://api.github.com/users/jorgutdev/events{/privacy}","received_events_url":"https://api.github.com/users/jorgutdev/received_events","type":"User","site_admin":false},"created_at":"2017-11-05T13:16:44Z","updated_at":"2017-11-05T13:16:44Z","author_association":"NONE","body":"@GantMan wow thanks so much! I didn't know that .merge was creating a new object ..."}}
{"actor":{"display_login":"jorgutdev"}}