{"action":"created","issue":{"url":"https://api.github.com/repos/pauldijou/redux-act/issues/25","repository_url":"https://api.github.com/repos/pauldijou/redux-act","labels_url":"https://api.github.com/repos/pauldijou/redux-act/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/pauldijou/redux-act/issues/25/comments","events_url":"https://api.github.com/repos/pauldijou/redux-act/issues/25/events","html_url":"https://github.com/pauldijou/redux-act/issues/25","id":158406654,"number":25,"title":"allow for composing reducers returned by createReducer?","user":{"login":"deanius","id":24406,"avatar_url":"https://avatars.githubusercontent.com/u/24406?v=3","gravatar_id":"","url":"https://api.github.com/users/deanius","html_url":"https://github.com/deanius","followers_url":"https://api.github.com/users/deanius/followers","following_url":"https://api.github.com/users/deanius/following{/other_user}","gists_url":"https://api.github.com/users/deanius/gists{/gist_id}","starred_url":"https://api.github.com/users/deanius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deanius/subscriptions","organizations_url":"https://api.github.com/users/deanius/orgs","repos_url":"https://api.github.com/users/deanius/repos","events_url":"https://api.github.com/users/deanius/events{/privacy}","received_events_url":"https://api.github.com/users/deanius/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-03T16:36:20Z","updated_at":"2016-06-06T03:15:21Z","closed_at":null,"body":"Hi, I'm wondering if this is a general pattern:\r\n\r\nAfter creating a reducer via `combineReducers`, where each sub-reducer minds its own part of the state tree, I want to apply some `preReducers` that do 'global' state mutations and which pre-empt the behavior of the others. I've written this code:\r\n\r\n```\r\n(origReducer, preReducers = []) => {\r\n  // return a reducer which calls origReducer only if none of the prereducers has changed the state\r\n  return (state, action) => {\r\n    for(let reducer of preReducers) {\r\n      let newState = reducer(state, action)\r\n      if (newState != state) return newState\r\n    }\r\n\r\n    return origReducer(state, action)\r\n  }\r\n}\r\n```\r\n\r\nMy question is do you think this is deserving of its own name or case in this library? Example use cases are global reducers that might move parts of the state tree around, or otherwise break the narrow guidelines laid down by `combineReducers`. Thanks, Dean"},"comment":{"url":"https://api.github.com/repos/pauldijou/redux-act/issues/comments/223860496","html_url":"https://github.com/pauldijou/redux-act/issues/25#issuecomment-223860496","issue_url":"https://api.github.com/repos/pauldijou/redux-act/issues/25","id":223860496,"user":{"login":"deanius","id":24406,"avatar_url":"https://avatars.githubusercontent.com/u/24406?v=3","gravatar_id":"","url":"https://api.github.com/users/deanius","html_url":"https://github.com/deanius","followers_url":"https://api.github.com/users/deanius/followers","following_url":"https://api.github.com/users/deanius/following{/other_user}","gists_url":"https://api.github.com/users/deanius/gists{/gist_id}","starred_url":"https://api.github.com/users/deanius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deanius/subscriptions","organizations_url":"https://api.github.com/users/deanius/orgs","repos_url":"https://api.github.com/users/deanius/repos","events_url":"https://api.github.com/users/deanius/events{/privacy}","received_events_url":"https://api.github.com/users/deanius/received_events","type":"User","site_admin":false},"created_at":"2016-06-06T03:15:21Z","updated_at":"2016-06-06T03:15:21Z","body":"Since your lib has code to create reducers out of existing reduction functions, I just offered up another way to create reducers out of reduction functions, with slightly different semantics, in case you saw a use for it. It has nothing to do with whether it runs in a middleware or not, I suspect the word 'global' triggered that association, but it's got nothing to do with that, really."}}
{"actor":{"display_login":"deanius"}}