{"action":"created","issue":{"url":"https://api.github.com/repos/airbnb/MvRx/issues/139","repository_url":"https://api.github.com/repos/airbnb/MvRx","labels_url":"https://api.github.com/repos/airbnb/MvRx/issues/139/labels{/name}","comments_url":"https://api.github.com/repos/airbnb/MvRx/issues/139/comments","events_url":"https://api.github.com/repos/airbnb/MvRx/issues/139/events","html_url":"https://github.com/airbnb/MvRx/issues/139","id":381017966,"node_id":"MDU6SXNzdWUzODEwMTc5NjY=","number":139,"title":"Reducer in `(S) -> S` format","user":{"login":"hellohuanlin","id":41930132,"node_id":"MDQ6VXNlcjQxOTMwMTMy","avatar_url":"https://avatars2.githubusercontent.com/u/41930132?v=4","gravatar_id":"","url":"https://api.github.com/users/hellohuanlin","html_url":"https://github.com/hellohuanlin","followers_url":"https://api.github.com/users/hellohuanlin/followers","following_url":"https://api.github.com/users/hellohuanlin/following{/other_user}","gists_url":"https://api.github.com/users/hellohuanlin/gists{/gist_id}","starred_url":"https://api.github.com/users/hellohuanlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hellohuanlin/subscriptions","organizations_url":"https://api.github.com/users/hellohuanlin/orgs","repos_url":"https://api.github.com/users/hellohuanlin/repos","events_url":"https://api.github.com/users/hellohuanlin/events{/privacy}","received_events_url":"https://api.github.com/users/hellohuanlin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-15T06:25:50Z","updated_at":"2018-11-15T16:22:52Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I am wondering if you are open to change reducers to `(S) -> S` format instead of `S.() -> S`. \r\n\r\n1. `(S) -> S` is more readable and easier to understand than `S.() -> S`\r\n2. An instance function represents a \"belong to\" relationship with the instance. A reducer is a function that maps S1 to S2, which i don't think it fits the definition well. \r\n3. Recently I have a careless bug: \r\n```\r\n// my state here: \r\ndata class State(\r\n  val extension: Extension\r\n)\r\ndata class Extension(\r\n  val val = 0\r\n)\r\n\r\n// my reducer here\r\n{\r\n  reduce(payload) // this line updates the extension\r\n    .copy(extension.copy(val=1)) // this line uses the old copy of extension\r\n}\r\n```\r\nIt's very easy to make this kind of mistakes with implicit parameter. \r\nHowever, with `(S1) -> S2` format, where I have to explicitly specify which state's extension to use, it's much harder to make such mistakes. \r\n\r\n@gpeal @BenSchwab @elihart "},"comment":{"url":"https://api.github.com/repos/airbnb/MvRx/issues/comments/439099559","html_url":"https://github.com/airbnb/MvRx/issues/139#issuecomment-439099559","issue_url":"https://api.github.com/repos/airbnb/MvRx/issues/139","id":439099559,"node_id":"MDEyOklzc3VlQ29tbWVudDQzOTA5OTU1OQ==","user":{"login":"hellohuanlin","id":41930132,"node_id":"MDQ6VXNlcjQxOTMwMTMy","avatar_url":"https://avatars2.githubusercontent.com/u/41930132?v=4","gravatar_id":"","url":"https://api.github.com/users/hellohuanlin","html_url":"https://github.com/hellohuanlin","followers_url":"https://api.github.com/users/hellohuanlin/followers","following_url":"https://api.github.com/users/hellohuanlin/following{/other_user}","gists_url":"https://api.github.com/users/hellohuanlin/gists{/gist_id}","starred_url":"https://api.github.com/users/hellohuanlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hellohuanlin/subscriptions","organizations_url":"https://api.github.com/users/hellohuanlin/orgs","repos_url":"https://api.github.com/users/hellohuanlin/repos","events_url":"https://api.github.com/users/hellohuanlin/events{/privacy}","received_events_url":"https://api.github.com/users/hellohuanlin/received_events","type":"User","site_admin":false},"created_at":"2018-11-15T16:22:52Z","updated_at":"2018-11-15T16:22:52Z","author_association":"CONTRIBUTOR","body":"extension.copy(val=1) would be error for `(S1) -> S2`"}}
{"actor":{"display_login":"hellohuanlin"}}