{"action":"created","issue":{"url":"https://api.github.com/repos/WordPress/gutenberg/issues/4839","repository_url":"https://api.github.com/repos/WordPress/gutenberg","labels_url":"https://api.github.com/repos/WordPress/gutenberg/issues/4839/labels{/name}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/issues/4839/comments","events_url":"https://api.github.com/repos/WordPress/gutenberg/issues/4839/events","html_url":"https://github.com/WordPress/gutenberg/pull/4839","id":293975026,"number":4839,"title":"Add withSafeTimeout higher-order component","user":{"login":"mcsf","id":150562,"avatar_url":"https://avatars0.githubusercontent.com/u/150562?v=4","gravatar_id":"","url":"https://api.github.com/users/mcsf","html_url":"https://github.com/mcsf","followers_url":"https://api.github.com/users/mcsf/followers","following_url":"https://api.github.com/users/mcsf/following{/other_user}","gists_url":"https://api.github.com/users/mcsf/gists{/gist_id}","starred_url":"https://api.github.com/users/mcsf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcsf/subscriptions","organizations_url":"https://api.github.com/users/mcsf/orgs","repos_url":"https://api.github.com/users/mcsf/repos","events_url":"https://api.github.com/users/mcsf/events{/privacy}","received_events_url":"https://api.github.com/users/mcsf/received_events","type":"User","site_admin":false},"labels":[{"id":562969841,"url":"https://api.github.com/repos/WordPress/gutenberg/labels/Framework","name":"Framework","color":"fbca04","default":false},{"id":587343997,"url":"https://api.github.com/repos/WordPress/gutenberg/labels/[Status]%20In%20Progress","name":"[Status] In Progress","color":"0052cc","default":false},{"id":531680828,"url":"https://api.github.com/repos/WordPress/gutenberg/labels/[Type]%20Question","name":"[Type] Question","color":"cc317c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-02T18:05:51Z","updated_at":"2018-02-05T10:33:21Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/WordPress/gutenberg/pulls/4839","html_url":"https://github.com/WordPress/gutenberg/pull/4839","diff_url":"https://github.com/WordPress/gutenberg/pull/4839.diff","patch_url":"https://github.com/WordPress/gutenberg/pull/4839.patch"},"body":"## Description\r\n\r\nSparked by recent _in situ_ conversations and by #4603, here's an attempt to make asynchronous function calling safer using a lifecycle-bound `setTimeout` equivalent.\r\n\r\nDepending on use cases, I could also see this accommodating more functions (`setInterval`, perhaps even `debounce`), whether via HoC arguments or separate HoCs.\r\n\r\n## How Has This Been Tested?\r\n\r\n1. Apply [this patch](https://gist.github.com/mcsf/1cb6c61d7bf392372f9189cb36c2813f) to tweak `CopyContentButton`'s behavior.\r\n2. Go to the editor, open the console.\r\n3. Open the global ellipsis menu. Click _Copy All Content_.\r\n4. Leave the menu open. Make sure that, after a second, the console logs `copied`.\r\n5. Open the ellipsis menu again. Click _Copy All Content_ and immediately close the menu.\r\n6. Make sure that the console _doesn't_ log `copied` after that.\r\n7. In `editor/hooks/copy-content/index.js`, replace the `setSafeTimeout( … )` call with the standard `window.setTimeout`. Repeat step 5 and make sure that the message gets logged even though the menu was previously closed.\r\n\r\n## Screenshots (jpeg or gifs if applicable):\r\n\r\n## Types of changes\r\n<!-- What types of changes does your code introduce?  -->\r\n<!-- Bug fix (non-breaking change which fixes an issue) -->\r\n<!-- New feature (non-breaking change which adds functionality) -->\r\n<!-- Breaking change (fix or feature that would cause existing functionality to not work as expected) -->\r\n\r\n## Checklist:\r\n- [ ] My code is tested.\r\n- [ ] My code follows the WordPress code style.\r\n- [ ] My code has proper inline documentation.\r\n"},"comment":{"url":"https://api.github.com/repos/WordPress/gutenberg/issues/comments/363044647","html_url":"https://github.com/WordPress/gutenberg/pull/4839#issuecomment-363044647","issue_url":"https://api.github.com/repos/WordPress/gutenberg/issues/4839","id":363044647,"user":{"login":"iseulde","id":4710635,"avatar_url":"https://avatars3.githubusercontent.com/u/4710635?v=4","gravatar_id":"","url":"https://api.github.com/users/iseulde","html_url":"https://github.com/iseulde","followers_url":"https://api.github.com/users/iseulde/followers","following_url":"https://api.github.com/users/iseulde/following{/other_user}","gists_url":"https://api.github.com/users/iseulde/gists{/gist_id}","starred_url":"https://api.github.com/users/iseulde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iseulde/subscriptions","organizations_url":"https://api.github.com/users/iseulde/orgs","repos_url":"https://api.github.com/users/iseulde/repos","events_url":"https://api.github.com/users/iseulde/events{/privacy}","received_events_url":"https://api.github.com/users/iseulde/received_events","type":"User","site_admin":false},"created_at":"2018-02-05T10:33:21Z","updated_at":"2018-02-05T10:33:21Z","author_association":"MEMBER","body":"At first I thought the `editor.removed` check was still needed in editable, but by then the timeout should be cleared anyway, so this seems useful there too.\r\n\r\nDo you think it should be called `setSafeTimeout` or just `setTimeout`, if it comes from props and if we may want to expand it?"}}
{"actor":{"display_login":"iseulde"}}