{"action":"created","issue":{"url":"https://api.github.com/repos/w3c/requestidlecallback/issues/11","labels_url":"https://api.github.com/repos/w3c/requestidlecallback/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/w3c/requestidlecallback/issues/11/comments","events_url":"https://api.github.com/repos/w3c/requestidlecallback/issues/11/events","html_url":"https://github.com/w3c/requestidlecallback/issues/11","id":100606518,"number":11,"title":"Collapse deadline and isExeeded into single function?","user":{"login":"igrigorik","id":10652,"avatar_url":"https://avatars.githubusercontent.com/u/10652?v=3","gravatar_id":"","url":"https://api.github.com/users/igrigorik","html_url":"https://github.com/igrigorik","followers_url":"https://api.github.com/users/igrigorik/followers","following_url":"https://api.github.com/users/igrigorik/following{/other_user}","gists_url":"https://api.github.com/users/igrigorik/gists{/gist_id}","starred_url":"https://api.github.com/users/igrigorik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igrigorik/subscriptions","organizations_url":"https://api.github.com/users/igrigorik/orgs","repos_url":"https://api.github.com/users/igrigorik/repos","events_url":"https://api.github.com/users/igrigorik/events{/privacy}","received_events_url":"https://api.github.com/users/igrigorik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-12T18:33:10Z","updated_at":"2015-08-19T09:33:08Z","closed_at":null,"body":"```\r\ninterface IdleDeadline {\r\n    readonly    attribute DOMHighResTimeStamp deadline;\r\n    readonly    attribute boolean             didTimeout;\r\n\r\n    boolean isExceeded();\r\n};\r\n```\r\n\r\nWould it make sense to simplify the above interface by collapsing `deadline` and `isExceeded` into a single function? For example, `timeLeft()`, or some such, that reports the amount of time left in the idle period? The developer API would then be...\r\n\r\n```javascript\r\nfunction doSomeIdleWork(deadline) {\r\n while (deadline.timeLeft() > 0) {\r\n  // ... do work here ...\r\n }\r\n window.requestIdleCallback(doSomeIdleWork);\r\n}\r\nwindow.requestIdleCallback(doSomeIdleWork);\r\n```\r\n\r\nAlso, on the implementation side for the reported estimate, we probably need to add some quantization logic for idle periods... E.g. multiples of ~2ms for <16ms, and millisecond granularity for >16ms.\r\n\r\n/cc @esprehn @ojanvafai "},"comment":{"url":"https://api.github.com/repos/w3c/requestidlecallback/issues/comments/132508981","html_url":"https://github.com/w3c/requestidlecallback/issues/11#issuecomment-132508981","issue_url":"https://api.github.com/repos/w3c/requestidlecallback/issues/11","id":132508981,"user":{"login":"rmcilroy","id":797814,"avatar_url":"https://avatars.githubusercontent.com/u/797814?v=3","gravatar_id":"","url":"https://api.github.com/users/rmcilroy","html_url":"https://github.com/rmcilroy","followers_url":"https://api.github.com/users/rmcilroy/followers","following_url":"https://api.github.com/users/rmcilroy/following{/other_user}","gists_url":"https://api.github.com/users/rmcilroy/gists{/gist_id}","starred_url":"https://api.github.com/users/rmcilroy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmcilroy/subscriptions","organizations_url":"https://api.github.com/users/rmcilroy/orgs","repos_url":"https://api.github.com/users/rmcilroy/repos","events_url":"https://api.github.com/users/rmcilroy/events{/privacy}","received_events_url":"https://api.github.com/users/rmcilroy/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T09:33:08Z","updated_at":"2015-08-19T09:33:08Z","body":"> I'm processing smaller work chunks (e.g. running in a loop), then the timeLeft approach is better \r\n> because it allows the system to adjust the reported value if we get descheduled.\r\n\r\nEither the `isExceeded()` or `performance.now() > deadline` would also allow the system to adjust the reported amount of time remaining (via the fact that `performance.now()` would increase while we are descheduled), so I don't think `timeLeft` is better for this reason, but it seems like a reasonable simplification to the API."}}