{"action":"created","issue":{"url":"https://api.github.com/repos/gaearon/react-redux/issues/16","labels_url":"https://api.github.com/repos/gaearon/react-redux/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/gaearon/react-redux/issues/16/comments","events_url":"https://api.github.com/repos/gaearon/react-redux/issues/16/events","html_url":"https://github.com/gaearon/react-redux/pull/16","id":98326047,"number":16,"title":"New API for connectDecorator implementation","user":{"login":"gnoff","id":2716369,"avatar_url":"https://avatars.githubusercontent.com/u/2716369?v=3","gravatar_id":"","url":"https://api.github.com/users/gnoff","html_url":"https://github.com/gnoff","followers_url":"https://api.github.com/users/gnoff/followers","following_url":"https://api.github.com/users/gnoff/following{/other_user}","gists_url":"https://api.github.com/users/gnoff/gists{/gist_id}","starred_url":"https://api.github.com/users/gnoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnoff/subscriptions","organizations_url":"https://api.github.com/users/gnoff/orgs","repos_url":"https://api.github.com/users/gnoff/repos","events_url":"https://api.github.com/users/gnoff/events{/privacy}","received_events_url":"https://api.github.com/users/gnoff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-07-31T06:38:22Z","updated_at":"2015-08-02T18:03:47Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/gaearon/react-redux/pulls/16","html_url":"https://github.com/gaearon/react-redux/pull/16","diff_url":"https://github.com/gaearon/react-redux/pull/16.diff","patch_url":"https://github.com/gaearon/react-redux/pull/16.patch"},"body":"Alright,\r\n\r\nHere's my take on the new connectDecorator API. Normal Args examples should all work from @gaearon 's comment in #1 \r\n\r\nhttps://github.com/gaearon/react-redux/issues/1#issuecomment-120729921\r\n\r\n### API\r\n```javascript\r\ndecorate = connect(\r\n  (State => StateAny) | null,\r\n  ?((Dispatch => DispatchAny) | actionsObject),\r\n  ?(StateAny, DispatchAny, ParentProps => Props)\r\n)\r\n\r\nMyConnectedComponent = decorate(PlainComponent)\r\n\r\n//annotation syntax\r\n@connect(\r\n   (State => StateAny) | null,\r\n  ?(Dispatch => DispatchAny),\r\n  ?(StateAny, DispatchAny, ParentProps => Props))\r\nComponent\r\n\r\n//component with decoration\r\nComponent\r\n\r\n//original component\r\nComponent.DecoratedComponent\r\n  \r\n```\r\n\r\n~~I didn't delete createConnector but I did move createConnectDecorator to createConnectDecoratorDeprecated until we can decide if we should just delete these.~~\r\n\r\nthe old Connector and connect decorator have been deleted\r\n\r\nI have tested through mocha only so no guarantees it is 100%\r\n\r\nI'm happy to make changes/work on it etc... as opinions change on best api going forward if it's not ready to merge yet.\r\n\r\nState is handled like Connector did on any notification from the store. shouldComponentUpdate will bail if the slice is the same\r\n\r\nactions are bound using the provided dispatchBinder (2nd arg) only on component mount. Not sure if this is what you were aiming for in the API but it certainly reduces the number of binds to a lot less than every render and it seemed find since the typical use case for dispatchBinder is to simply bind dispatch to the action creator methods\r\n\r\nmerge is called on every render, reading stateProps and dispatchBinderProps from component state (not store state) and taking whatever current component props as the 3rd argument.\r\n\r\n~~finally the decorated component is rendered with this.props, and mergedProps in that order.~~\r\nIf you want choose to provide a custom merge function then only the props returned from merge will be added to the underlying component\r\n\r\nI also wrote a util for wrapActionCreators that fits the dispatchBinder argument signature and delegates to redux/bindActionCreators. This is called form connectDecorator if the actionCreators argument is a plain object"},"comment":{"url":"https://api.github.com/repos/gaearon/react-redux/issues/comments/127051086","html_url":"https://github.com/gaearon/react-redux/pull/16#issuecomment-127051086","issue_url":"https://api.github.com/repos/gaearon/react-redux/issues/16","id":127051086,"user":{"login":"Keats","id":680355,"avatar_url":"https://avatars.githubusercontent.com/u/680355?v=3","gravatar_id":"","url":"https://api.github.com/users/Keats","html_url":"https://github.com/Keats","followers_url":"https://api.github.com/users/Keats/followers","following_url":"https://api.github.com/users/Keats/following{/other_user}","gists_url":"https://api.github.com/users/Keats/gists{/gist_id}","starred_url":"https://api.github.com/users/Keats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Keats/subscriptions","organizations_url":"https://api.github.com/users/Keats/orgs","repos_url":"https://api.github.com/users/Keats/repos","events_url":"https://api.github.com/users/Keats/events{/privacy}","received_events_url":"https://api.github.com/users/Keats/received_events","type":"User","site_admin":false},"created_at":"2015-08-02T18:03:47Z","updated_at":"2015-08-02T18:03:47Z","body":"@quirinpa I'm not the one that did the PR!\r\nIt's @gnoff "}}