{"action":"created","issue":{"url":"https://api.github.com/repos/knockout/knockout/issues/1738","labels_url":"https://api.github.com/repos/knockout/knockout/issues/1738/labels{/name}","comments_url":"https://api.github.com/repos/knockout/knockout/issues/1738/comments","events_url":"https://api.github.com/repos/knockout/knockout/issues/1738/events","html_url":"https://github.com/knockout/knockout/pull/1738","id":63136730,"number":1738,"title":"Deferred updates, part 1: task scheduler, extender, tests","user":{"login":"mbest","id":1230364,"avatar_url":"https://avatars.githubusercontent.com/u/1230364?v=3","gravatar_id":"","url":"https://api.github.com/users/mbest","html_url":"https://github.com/mbest","followers_url":"https://api.github.com/users/mbest/followers","following_url":"https://api.github.com/users/mbest/following{/other_user}","gists_url":"https://api.github.com/users/mbest/gists{/gist_id}","starred_url":"https://api.github.com/users/mbest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbest/subscriptions","organizations_url":"https://api.github.com/users/mbest/orgs","repos_url":"https://api.github.com/users/mbest/repos","events_url":"https://api.github.com/users/mbest/events{/privacy}","received_events_url":"https://api.github.com/users/mbest/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/knockout/knockout/milestones/8","html_url":"https://github.com/knockout/knockout/milestones/3.4.0","labels_url":"https://api.github.com/repos/knockout/knockout/milestones/8/labels","id":926494,"number":8,"title":"3.4.0","description":null,"creator":{"login":"brianmhunt","id":135528,"avatar_url":"https://avatars.githubusercontent.com/u/135528?v=3","gravatar_id":"","url":"https://api.github.com/users/brianmhunt","html_url":"https://github.com/brianmhunt","followers_url":"https://api.github.com/users/brianmhunt/followers","following_url":"https://api.github.com/users/brianmhunt/following{/other_user}","gists_url":"https://api.github.com/users/brianmhunt/gists{/gist_id}","starred_url":"https://api.github.com/users/brianmhunt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianmhunt/subscriptions","organizations_url":"https://api.github.com/users/brianmhunt/orgs","repos_url":"https://api.github.com/users/brianmhunt/repos","events_url":"https://api.github.com/users/brianmhunt/events{/privacy}","received_events_url":"https://api.github.com/users/brianmhunt/received_events","type":"User","site_admin":false},"open_issues":27,"closed_issues":1,"state":"open","created_at":"2015-01-08T01:57:00Z","updated_at":"2015-03-20T02:24:38Z","due_on":null,"closed_at":null},"comments":10,"created_at":"2015-03-20T01:53:31Z","updated_at":"2015-03-28T00:02:33Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/knockout/knockout/pulls/1738","html_url":"https://github.com/knockout/knockout/pull/1738","diff_url":"https://github.com/knockout/knockout/pull/1738.diff","patch_url":"https://github.com/knockout/knockout/pull/1738.patch"},"body":"The additions here provide the means to efficiently make some actions asynchronous. The `ko.tasks` API includes the following methods for scheduling or canceling tasks:\r\n\r\n`ko.tasks.schedule( callback )` - Schedules a task to run asynchronously; returns a task handle\r\n`ko.tasks.cancel( handle )` - Cancels a scheduled task; does nothing if the task has already run\r\n\r\nThe following method are advanced and are useful for testing or for integrating with another task management system.\r\n\r\n`ko.tasks.runTasks( )` - Immediately runs all scheduled tasks. \r\n`ko.tasks.scheduler( function )` - Overwrite this method to define a different function for scheduling when to run tasks.\r\n\r\nThe `deferred` extender uses the above task scheduler to set up deferred notification for observables."},"comment":{"url":"https://api.github.com/repos/knockout/knockout/issues/comments/87127686","html_url":"https://github.com/knockout/knockout/pull/1738#issuecomment-87127686","issue_url":"https://api.github.com/repos/knockout/knockout/issues/1738","id":87127686,"user":{"login":"mbest","id":1230364,"avatar_url":"https://avatars.githubusercontent.com/u/1230364?v=3","gravatar_id":"","url":"https://api.github.com/users/mbest","html_url":"https://github.com/mbest","followers_url":"https://api.github.com/users/mbest/followers","following_url":"https://api.github.com/users/mbest/following{/other_user}","gists_url":"https://api.github.com/users/mbest/gists{/gist_id}","starred_url":"https://api.github.com/users/mbest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbest/subscriptions","organizations_url":"https://api.github.com/users/mbest/orgs","repos_url":"https://api.github.com/users/mbest/repos","events_url":"https://api.github.com/users/mbest/events{/privacy}","received_events_url":"https://api.github.com/users/mbest/received_events","type":"User","site_admin":false},"created_at":"2015-03-28T00:02:33Z","updated_at":"2015-03-28T00:02:33Z","body":"Regarding the async scheduler, I decide to test the various methods to compare their effectiveness at reducing layouts and paints. My test updates one observable synchronously and another asynchronously using the selected method. Both toggle a section of the page, using the `if` binding.\r\n\r\n*setTimeout* - Two layouts, two paints.\r\n*postMessge* - Two layouts, two paints.\r\n*requestAnimationFrame* - Varies. In Chrome, one paint, but sometimes two layouts. In IE, two layouts and two paints.\r\n*MutationObserver* - Always one layout and one paint.\r\n*onreadystatechange* - (IE only) Always one layout and one paint.\r\n"}}