{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6645","repository_url":"https://api.github.com/repos/Automattic/wp-calypso","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6645/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6645/comments","events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6645/events","html_url":"https://github.com/Automattic/wp-calypso/pull/6645","id":164603639,"number":6645,"title":"State / CPT: Create notices middleware for observing actions","user":{"login":"aduth","id":1779930,"avatar_url":"https://avatars.githubusercontent.com/u/1779930?v=3","gravatar_id":"","url":"https://api.github.com/users/aduth","html_url":"https://github.com/aduth","followers_url":"https://api.github.com/users/aduth/followers","following_url":"https://api.github.com/users/aduth/following{/other_user}","gists_url":"https://api.github.com/users/aduth/gists{/gist_id}","starred_url":"https://api.github.com/users/aduth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aduth/subscriptions","organizations_url":"https://api.github.com/users/aduth/orgs","repos_url":"https://api.github.com/users/aduth/repos","events_url":"https://api.github.com/users/aduth/events{/privacy}","received_events_url":"https://api.github.com/users/aduth/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/Custom%20Post%20Types%20(CPT)","name":"Custom Post Types (CPT)","color":"006b75"},{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/State","name":"State","color":"006b75"},{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/[Status]%20Needs%20Review","name":"[Status] Needs Review","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-07-08T19:50:08Z","updated_at":"2016-07-13T16:10:17Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6645","html_url":"https://github.com/Automattic/wp-calypso/pull/6645","diff_url":"https://github.com/Automattic/wp-calypso/pull/6645.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/6645.patch"},"body":"Related: #6536\r\nRelated: #6306\r\n\r\nThis pull request seeks to explore a new middleware for notices to enable monitoring action types and dispatching notice creation in response to those actions. The advantage of this approach over earlier iterations (#6306) is that in using the reducer for observing actions, we don't have access to the entire global state. This makes it difficult to customize the notice, for example including the title of a post when a delete fails, since the action only contains the post and site IDs.\r\n\r\nSince the middleware signature allows access to the entire global state, we can make use of any existing selector to retrieve data outside of the action or notices state. It also simplifies and removes redundancy in creating the notices by reusing existing action creators and the reducer behaviors corresponding to those action types.\r\n\r\n![Delete failure with title](https://cloud.githubusercontent.com/assets/1779930/16699579/e90cc446-4522-11e6-9777-a7ec66129da1.png)\r\n\r\n__Testing instructions:__\r\n\r\nRepeat testing instructions from #6536 \r\n\r\n__Follow-up tasks:__\r\n\r\nI still think it'd be worth exploring expanding this middleware to capture `meta` directly from the action, as mentioned at https://github.com/Automattic/wp-calypso/pull/6306#discussion_r69541313 .\r\n\r\n/cc @mtias @gwwar @artpi \n\nTest live: https://calypso.live/?branch=add/notices-middleware"},"comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments/232404965","html_url":"https://github.com/Automattic/wp-calypso/pull/6645#issuecomment-232404965","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6645","id":232404965,"user":{"login":"blowery","id":14350,"avatar_url":"https://avatars.githubusercontent.com/u/14350?v=3","gravatar_id":"","url":"https://api.github.com/users/blowery","html_url":"https://github.com/blowery","followers_url":"https://api.github.com/users/blowery/followers","following_url":"https://api.github.com/users/blowery/following{/other_user}","gists_url":"https://api.github.com/users/blowery/gists{/gist_id}","starred_url":"https://api.github.com/users/blowery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blowery/subscriptions","organizations_url":"https://api.github.com/users/blowery/orgs","repos_url":"https://api.github.com/users/blowery/repos","events_url":"https://api.github.com/users/blowery/events{/privacy}","received_events_url":"https://api.github.com/users/blowery/received_events","type":"User","site_admin":false},"created_at":"2016-07-13T16:10:17Z","updated_at":"2016-07-13T16:10:17Z","body":"Ah! So much has happened. To respond to one thing I mentioned in a code diff with @dmsnell ...\r\n\r\n>  I do not think that the reader should care or know anything about notices. why should it? the reader knows that it needs to tell Calypso to delete a post or something like that - end of story.\r\n\r\nMy concern with having all of the notice responders in one file has less to do with who-knows-what and more to do with bundle size. I agree the \"reader\" (ie, stuff that lives in client/reader) shouldn't know a darn thing about notices. I think the action creators _may_ know about them, but ideally they don't. So then who does know about them, and how do we decide which bundle they should get pulled into?\r\n\r\nWith the current layout, these will likely end up in the commons. That's probably ok, but as I mentioned, if one loads the reader and nothing else, code that handles actions that never fire (and _can_ never fire) also loads. This is true here, and for our reducer tree. Both are pulling in everything that could possibly happen from the start. I think this is unnecessary bloat and we're going to want / need a system to patch things into the reducer tree dynamically down the road. Our bundles are already pretty darn large. Making large parts of the app global isn't going to help that concern. \r\n"}}
{"actor":{"display_login":"blowery"}}