{"action":"created","issue":{"url":"https://api.github.com/repos/whatwg/html/issues/512","labels_url":"https://api.github.com/repos/whatwg/html/issues/512/labels{/name}","comments_url":"https://api.github.com/repos/whatwg/html/issues/512/comments","events_url":"https://api.github.com/repos/whatwg/html/issues/512/events","html_url":"https://github.com/whatwg/html/issues/512","id":126521952,"number":512,"title":"Proposal: window.enqueueMicrotask(f)","user":{"login":"domenic","id":617481,"avatar_url":"https://avatars.githubusercontent.com/u/617481?v=3","gravatar_id":"","url":"https://api.github.com/users/domenic","html_url":"https://github.com/domenic","followers_url":"https://api.github.com/users/domenic/followers","following_url":"https://api.github.com/users/domenic/following{/other_user}","gists_url":"https://api.github.com/users/domenic/gists{/gist_id}","starred_url":"https://api.github.com/users/domenic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domenic/subscriptions","organizations_url":"https://api.github.com/users/domenic/orgs","repos_url":"https://api.github.com/users/domenic/repos","events_url":"https://api.github.com/users/domenic/events{/privacy}","received_events_url":"https://api.github.com/users/domenic/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/whatwg/html/labels/addition/proposal","name":"addition/proposal","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":31,"created_at":"2016-01-13T21:41:48Z","updated_at":"2016-01-18T18:06:29Z","closed_at":null,"body":"In talking with the Angular team (mostly @mhevery), there is interest in a simple low-level method for enqueuing a microtask from author code. I've heard this from a number of authors in the past. It seems simple enough and easy to add to the spec, if we can get any other implementations besides Chrome interested.\r\n\r\nRight now authors are doing this via a number of [hacks](https://github.com/kriskowal/asap), like creating a text node and a MutationObserver and twiddling the text node every time they want to trigger a microtask, or using `Promise.resolve().then(f)` (which creates a promise object and stores any thrown errors there, instead of letting them propagate to \"report an exception\").\r\n\r\nThere are many use cases, which I'm sure we can assemble in depth, but let me just start with the following reasons which will hopefully be enough to convince people:\r\n\r\n- From an academic point of view, this is a low-level primitive and there's no reason to lock it up behind higher-level concepts like promises and mutation observers.\r\n- From a practical point of view, libraries very often want to guarantee asynchrony (to [avoid Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)), without taking the overhead of a full \"macro\" task like `setTimeout(f, 0)`.\r\n\r\n**I'd like to first focus this thread on finding implementer support: if we spec this, will you implement it? _After that_, we can start bikeshedding the name; please don't do so beforehand.**\r\n\r\n/ccing some implementers: @hober @travisleithead @bzbarsky "},"comment":{"url":"https://api.github.com/repos/whatwg/html/issues/comments/172609067","html_url":"https://github.com/whatwg/html/issues/512#issuecomment-172609067","issue_url":"https://api.github.com/repos/whatwg/html/issues/512","id":172609067,"user":{"login":"domenic","id":617481,"avatar_url":"https://avatars.githubusercontent.com/u/617481?v=3","gravatar_id":"","url":"https://api.github.com/users/domenic","html_url":"https://github.com/domenic","followers_url":"https://api.github.com/users/domenic/followers","following_url":"https://api.github.com/users/domenic/following{/other_user}","gists_url":"https://api.github.com/users/domenic/gists{/gist_id}","starred_url":"https://api.github.com/users/domenic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domenic/subscriptions","organizations_url":"https://api.github.com/users/domenic/orgs","repos_url":"https://api.github.com/users/domenic/repos","events_url":"https://api.github.com/users/domenic/events{/privacy}","received_events_url":"https://api.github.com/users/domenic/received_events","type":"User","site_admin":false},"created_at":"2016-01-18T18:06:29Z","updated_at":"2016-01-18T18:06:29Z","body":"Blink is interested, so I guess Gecko does not have zero interest :)"}}