{"action":"created","issue":{"url":"https://api.github.com/repos/permettez-moi-de-construire/cancellable-promise/issues/1","repository_url":"https://api.github.com/repos/permettez-moi-de-construire/cancellable-promise","labels_url":"https://api.github.com/repos/permettez-moi-de-construire/cancellable-promise/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/permettez-moi-de-construire/cancellable-promise/issues/1/comments","events_url":"https://api.github.com/repos/permettez-moi-de-construire/cancellable-promise/issues/1/events","html_url":"https://github.com/permettez-moi-de-construire/cancellable-promise/pull/1","id":342689543,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAyNTI5MDI5","number":1,"title":"Update CancelToken.js","user":{"login":"njlr","id":1577531,"node_id":"MDQ6VXNlcjE1Nzc1MzE=","avatar_url":"https://avatars2.githubusercontent.com/u/1577531?v=4","gravatar_id":"","url":"https://api.github.com/users/njlr","html_url":"https://github.com/njlr","followers_url":"https://api.github.com/users/njlr/followers","following_url":"https://api.github.com/users/njlr/following{/other_user}","gists_url":"https://api.github.com/users/njlr/gists{/gist_id}","starred_url":"https://api.github.com/users/njlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njlr/subscriptions","organizations_url":"https://api.github.com/users/njlr/orgs","repos_url":"https://api.github.com/users/njlr/repos","events_url":"https://api.github.com/users/njlr/events{/privacy}","received_events_url":"https://api.github.com/users/njlr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-07-19T11:29:34Z","updated_at":"2018-07-19T17:31:57Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/permettez-moi-de-construire/cancellable-promise/pulls/1","html_url":"https://github.com/permettez-moi-de-construire/cancellable-promise/pull/1","diff_url":"https://github.com/permettez-moi-de-construire/cancellable-promise/pull/1.diff","patch_url":"https://github.com/permettez-moi-de-construire/cancellable-promise/pull/1.patch"},"body":"In order to make this library work correctly, the user must pass the cancellation token around and check its state. To make this more convenient, I would propose a method to \"check\" the token. \r\n\r\nUsage like this: \r\n\r\n```\r\nconst sleep = ms => new Promise((resolve) => {\r\n  setTimeout(() => {\r\n    resolve(ms);\r\n  }, ms);\r\n});\r\n\r\nconst token = new CancelToken();\r\n\r\n// This token has a 3 second time-out\r\nsleep(3000).then(token.cancel());\r\n\r\nconst p = sleep(5000).then(() => {\r\n  // Check the token has not been cancelled; \r\n  // without this, \"Hello, world. \" is always printed. \r\n  token.check();\r\n  console.log('Hello, world. ');\r\n});\r\n\r\nconst q = cancellablePromise(p, token);\r\n\r\nq.then(console.log).catch(console.error);\r\n```"},"comment":{"url":"https://api.github.com/repos/permettez-moi-de-construire/cancellable-promise/issues/comments/406355323","html_url":"https://github.com/permettez-moi-de-construire/cancellable-promise/pull/1#issuecomment-406355323","issue_url":"https://api.github.com/repos/permettez-moi-de-construire/cancellable-promise/issues/1","id":406355323,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNjM1NTMyMw==","user":{"login":"cyrilchapon","id":10728426,"node_id":"MDQ6VXNlcjEwNzI4NDI2","avatar_url":"https://avatars1.githubusercontent.com/u/10728426?v=4","gravatar_id":"","url":"https://api.github.com/users/cyrilchapon","html_url":"https://github.com/cyrilchapon","followers_url":"https://api.github.com/users/cyrilchapon/followers","following_url":"https://api.github.com/users/cyrilchapon/following{/other_user}","gists_url":"https://api.github.com/users/cyrilchapon/gists{/gist_id}","starred_url":"https://api.github.com/users/cyrilchapon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyrilchapon/subscriptions","organizations_url":"https://api.github.com/users/cyrilchapon/orgs","repos_url":"https://api.github.com/users/cyrilchapon/repos","events_url":"https://api.github.com/users/cyrilchapon/events{/privacy}","received_events_url":"https://api.github.com/users/cyrilchapon/received_events","type":"User","site_admin":false},"created_at":"2018-07-19T17:31:57Z","updated_at":"2018-07-19T17:31:57Z","author_association":"CONTRIBUTOR","body":"I should add that, in my first idea, I was not going to **actually cancel** the process or the first Promise I did wrap, but more like just ignore it's result."}}
{"actor":{"display_login":"cyrilchapon"}}