{"action":"created","comment":{"url":"https://api.github.com/repos/Polymer/lit-html/pulls/comments/229855427","pull_request_review_id":170456986,"id":229855427,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyOTg1NTQyNw==","diff_hunk":"@@ -0,0 +1,60 @@\n+/**\n+ * @license\n+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n+ * This code may only be used under the BSD style license found at\n+ * http://polymer.github.io/LICENSE.txt\n+ * The complete set of authors may be found at\n+ * http://polymer.github.io/AUTHORS.txt\n+ * The complete set of contributors may be found at\n+ * http://polymer.github.io/CONTRIBUTORS.txt\n+ * Code distributed by Google as part of the polymer project is also\n+ * subject to an additional IP rights grant found at\n+ * http://polymer.github.io/PATENTS.txt\n+ */\n+\n+import {directive, noChange, Part} from '../lit-html.js';\n+\n+interface PromisedValue {\n+  promise: Promise<unknown>;\n+  resolved: boolean;\n+}\n+\n+const promises = new WeakMap<Part, PromisedValue>();\n+\n+/**\n+ * Renders a Promise to a Part when it resolves. `defaultContent` will be\n+ * rendered until the Promise resolves.\n+ */\n+export const async = directive(\n+    (promise: Promise<any>,\n+     defaultContent: unknown = noChange) => (part: Part) => {\n+      let promisedValue = promises.get(part);\n+\n+      if (promisedValue !== undefined && promisedValue.promise === promise) {\n+        // Set the default content if the Promise hasn't resolved *even if\n+        // we're getting the same Promise* because the default content\n+        // could have changed.\n+        if (!promisedValue.resolved && defaultContent !== noChange) {\n+          part.setValue(defaultContent);\n+        }\n+        // If the Promise has resolved we simply return, as the value was\n+        // updated in the then() callback below.\n+        return;\n+      }\n+\n+      // The following code only ever runs once per Promise instance\n+      promisedValue = {promise, resolved: false};\n+      promises.set(part, promisedValue);\n+      if (defaultContent !== noChange) {\n+        part.setValue(defaultContent);\n+      }\n+\n+      Promise.resolve(promise).then((value: unknown) => {\n+        const currentPromisedValue = promises.get(part);\n+        if (currentPromisedValue !== promisedValue) {\n+          return;\n+        }\n+        part.setValue(value);","path":"src/directives/async.ts","position":null,"original_position":57,"commit_id":"ac8f1ac8a17491951f53d0b89cda6e5619d3067a","original_commit_id":"4369e05c3e8a127e52dd14aa0252f954a524b67a","user":{"login":"justinfagnani","id":522948,"node_id":"MDQ6VXNlcjUyMjk0OA==","avatar_url":"https://avatars0.githubusercontent.com/u/522948?v=4","gravatar_id":"","url":"https://api.github.com/users/justinfagnani","html_url":"https://github.com/justinfagnani","followers_url":"https://api.github.com/users/justinfagnani/followers","following_url":"https://api.github.com/users/justinfagnani/following{/other_user}","gists_url":"https://api.github.com/users/justinfagnani/gists{/gist_id}","starred_url":"https://api.github.com/users/justinfagnani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinfagnani/subscriptions","organizations_url":"https://api.github.com/users/justinfagnani/orgs","repos_url":"https://api.github.com/users/justinfagnani/repos","events_url":"https://api.github.com/users/justinfagnani/events{/privacy}","received_events_url":"https://api.github.com/users/justinfagnani/received_events","type":"User","site_admin":false},"body":"Added test that fails without setting `resolved`","created_at":"2018-10-31T20:27:43Z","updated_at":"2018-10-31T20:28:31Z","html_url":"https://github.com/Polymer/lit-html/pull/555#discussion_r229855427","pull_request_url":"https://api.github.com/repos/Polymer/lit-html/pulls/555","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/Polymer/lit-html/pulls/comments/229855427"},"html":{"href":"https://github.com/Polymer/lit-html/pull/555#discussion_r229855427"},"pull_request":{"href":"https://api.github.com/repos/Polymer/lit-html/pulls/555"}},"in_reply_to_id":226804617},"pull_request":{"url":"https://api.github.com/repos/Polymer/lit-html/pulls/555","id":221649544,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxNjQ5NTQ0","html_url":"https://github.com/Polymer/lit-html/pull/555","diff_url":"https://github.com/Polymer/lit-html/pull/555.diff","patch_url":"https://github.com/Polymer/lit-html/pull/555.patch","issue_url":"https://api.github.com/repos/Polymer/lit-html/issues/555","number":555,"state":"open","locked":false,"title":"Move Promise support to directives.","user":{"login":"justinfagnani","id":522948,"node_id":"MDQ6VXNlcjUyMjk0OA==","avatar_url":"https://avatars0.githubusercontent.com/u/522948?v=4","gravatar_id":"","url":"https://api.github.com/users/justinfagnani","html_url":"https://github.com/justinfagnani","followers_url":"https://api.github.com/users/justinfagnani/followers","following_url":"https://api.github.com/users/justinfagnani/following{/other_user}","gists_url":"https://api.github.com/users/justinfagnani/gists{/gist_id}","starred_url":"https://api.github.com/users/justinfagnani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinfagnani/subscriptions","organizations_url":"https://api.github.com/users/justinfagnani/orgs","repos_url":"https://api.github.com/users/justinfagnani/repos","events_url":"https://api.github.com/users/justinfagnani/events{/privacy}","received_events_url":"https://api.github.com/users/justinfagnani/received_events","type":"User","site_admin":false},"body":"Removes built-in Promise support. Adds an async() directive as a successor to until() that is required to render Promises. async() handles race conditions, works with attribute, boolean attribute, property and event bindings. It also works as a nested directive value with other directives like repeat().\r\n\r\nWhile this only removes a small amount of current core library code, more core code would have be required to handle attributes, etc., and the race conditions, mainly because current Part factoring has us sharing very little code between Part implementations. It’s possible that we could refactor Parts in the future to share more value-handling code and bring back built-in Promise support in the future. Adding that would not be a breaking change, but we need to remove support before 1.0 since removing later would be a breaking change.\r\n\r\nThis change keeps directives/until.js to re-export async to ease the transition. It’s deprecated and will be removed before 1.0.\r\n\r\nFixes #550 \r\nCloses #272, #544, #451 and #458","created_at":"2018-10-10T03:38:29Z","updated_at":"2018-10-31T20:28:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d2d791668c6e1e5f7ff4e6e913721663167f506d","assignee":null,"assignees":[],"requested_reviewers":[{"login":"sorvell","id":78891,"node_id":"MDQ6VXNlcjc4ODkx","avatar_url":"https://avatars1.githubusercontent.com/u/78891?v=4","gravatar_id":"","url":"https://api.github.com/users/sorvell","html_url":"https://github.com/sorvell","followers_url":"https://api.github.com/users/sorvell/followers","following_url":"https://api.github.com/users/sorvell/following{/other_user}","gists_url":"https://api.github.com/users/sorvell/gists{/gist_id}","starred_url":"https://api.github.com/users/sorvell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sorvell/subscriptions","organizations_url":"https://api.github.com/users/sorvell/orgs","repos_url":"https://api.github.com/users/sorvell/repos","events_url":"https://api.github.com/users/sorvell/events{/privacy}","received_events_url":"https://api.github.com/users/sorvell/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Polymer/lit-html/pulls/555/commits","review_comments_url":"https://api.github.com/repos/Polymer/lit-html/pulls/555/comments","review_comment_url":"https://api.github.com/repos/Polymer/lit-html/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Polymer/lit-html/issues/555/comments","statuses_url":"https://api.github.com/repos/Polymer/lit-html/statuses/ac8f1ac8a17491951f53d0b89cda6e5619d3067a","head":{"label":"Polymer:async-directive","ref":"async-directive","sha":"ac8f1ac8a17491951f53d0b89cda6e5619d3067a","user":{"login":"Polymer","id":2159051,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNTkwNTE=","avatar_url":"https://avatars3.githubusercontent.com/u/2159051?v=4","gravatar_id":"","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"repo":{"id":95797174,"node_id":"MDEwOlJlcG9zaXRvcnk5NTc5NzE3NA==","name":"lit-html","full_name":"Polymer/lit-html","private":false,"owner":{"login":"Polymer","id":2159051,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNTkwNTE=","avatar_url":"https://avatars3.githubusercontent.com/u/2159051?v=4","gravatar_id":"","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Polymer/lit-html","description":"HTML template literals in JavaScript","fork":false,"url":"https://api.github.com/repos/Polymer/lit-html","forks_url":"https://api.github.com/repos/Polymer/lit-html/forks","keys_url":"https://api.github.com/repos/Polymer/lit-html/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Polymer/lit-html/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Polymer/lit-html/teams","hooks_url":"https://api.github.com/repos/Polymer/lit-html/hooks","issue_events_url":"https://api.github.com/repos/Polymer/lit-html/issues/events{/number}","events_url":"https://api.github.com/repos/Polymer/lit-html/events","assignees_url":"https://api.github.com/repos/Polymer/lit-html/assignees{/user}","branches_url":"https://api.github.com/repos/Polymer/lit-html/branches{/branch}","tags_url":"https://api.github.com/repos/Polymer/lit-html/tags","blobs_url":"https://api.github.com/repos/Polymer/lit-html/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Polymer/lit-html/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Polymer/lit-html/git/refs{/sha}","trees_url":"https://api.github.com/repos/Polymer/lit-html/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Polymer/lit-html/statuses/{sha}","languages_url":"https://api.github.com/repos/Polymer/lit-html/languages","stargazers_url":"https://api.github.com/repos/Polymer/lit-html/stargazers","contributors_url":"https://api.github.com/repos/Polymer/lit-html/contributors","subscribers_url":"https://api.github.com/repos/Polymer/lit-html/subscribers","subscription_url":"https://api.github.com/repos/Polymer/lit-html/subscription","commits_url":"https://api.github.com/repos/Polymer/lit-html/commits{/sha}","git_commits_url":"https://api.github.com/repos/Polymer/lit-html/git/commits{/sha}","comments_url":"https://api.github.com/repos/Polymer/lit-html/comments{/number}","issue_comment_url":"https://api.github.com/repos/Polymer/lit-html/issues/comments{/number}","contents_url":"https://api.github.com/repos/Polymer/lit-html/contents/{+path}","compare_url":"https://api.github.com/repos/Polymer/lit-html/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Polymer/lit-html/merges","archive_url":"https://api.github.com/repos/Polymer/lit-html/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Polymer/lit-html/downloads","issues_url":"https://api.github.com/repos/Polymer/lit-html/issues{/number}","pulls_url":"https://api.github.com/repos/Polymer/lit-html/pulls{/number}","milestones_url":"https://api.github.com/repos/Polymer/lit-html/milestones{/number}","notifications_url":"https://api.github.com/repos/Polymer/lit-html/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Polymer/lit-html/labels{/name}","releases_url":"https://api.github.com/repos/Polymer/lit-html/releases{/id}","deployments_url":"https://api.github.com/repos/Polymer/lit-html/deployments","created_at":"2017-06-29T16:27:16Z","updated_at":"2018-10-31T19:14:27Z","pushed_at":"2018-10-31T20:28:29Z","git_url":"git://github.com/Polymer/lit-html.git","ssh_url":"git@github.com:Polymer/lit-html.git","clone_url":"https://github.com/Polymer/lit-html.git","svn_url":"https://github.com/Polymer/lit-html","homepage":"https://polymer.github.io/lit-html/","size":1821,"stargazers_count":3198,"watchers_count":3198,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":186,"mirror_url":null,"archived":false,"open_issues_count":96,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":186,"open_issues":96,"watchers":3198,"default_branch":"master"}},"base":{"label":"Polymer:master","ref":"master","sha":"bcc87cf6488fa414e5361a9d46d992f01c11517a","user":{"login":"Polymer","id":2159051,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNTkwNTE=","avatar_url":"https://avatars3.githubusercontent.com/u/2159051?v=4","gravatar_id":"","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"repo":{"id":95797174,"node_id":"MDEwOlJlcG9zaXRvcnk5NTc5NzE3NA==","name":"lit-html","full_name":"Polymer/lit-html","private":false,"owner":{"login":"Polymer","id":2159051,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNTkwNTE=","avatar_url":"https://avatars3.githubusercontent.com/u/2159051?v=4","gravatar_id":"","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Polymer/lit-html","description":"HTML template literals in JavaScript","fork":false,"url":"https://api.github.com/repos/Polymer/lit-html","forks_url":"https://api.github.com/repos/Polymer/lit-html/forks","keys_url":"https://api.github.com/repos/Polymer/lit-html/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Polymer/lit-html/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Polymer/lit-html/teams","hooks_url":"https://api.github.com/repos/Polymer/lit-html/hooks","issue_events_url":"https://api.github.com/repos/Polymer/lit-html/issues/events{/number}","events_url":"https://api.github.com/repos/Polymer/lit-html/events","assignees_url":"https://api.github.com/repos/Polymer/lit-html/assignees{/user}","branches_url":"https://api.github.com/repos/Polymer/lit-html/branches{/branch}","tags_url":"https://api.github.com/repos/Polymer/lit-html/tags","blobs_url":"https://api.github.com/repos/Polymer/lit-html/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Polymer/lit-html/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Polymer/lit-html/git/refs{/sha}","trees_url":"https://api.github.com/repos/Polymer/lit-html/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Polymer/lit-html/statuses/{sha}","languages_url":"https://api.github.com/repos/Polymer/lit-html/languages","stargazers_url":"https://api.github.com/repos/Polymer/lit-html/stargazers","contributors_url":"https://api.github.com/repos/Polymer/lit-html/contributors","subscribers_url":"https://api.github.com/repos/Polymer/lit-html/subscribers","subscription_url":"https://api.github.com/repos/Polymer/lit-html/subscription","commits_url":"https://api.github.com/repos/Polymer/lit-html/commits{/sha}","git_commits_url":"https://api.github.com/repos/Polymer/lit-html/git/commits{/sha}","comments_url":"https://api.github.com/repos/Polymer/lit-html/comments{/number}","issue_comment_url":"https://api.github.com/repos/Polymer/lit-html/issues/comments{/number}","contents_url":"https://api.github.com/repos/Polymer/lit-html/contents/{+path}","compare_url":"https://api.github.com/repos/Polymer/lit-html/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Polymer/lit-html/merges","archive_url":"https://api.github.com/repos/Polymer/lit-html/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Polymer/lit-html/downloads","issues_url":"https://api.github.com/repos/Polymer/lit-html/issues{/number}","pulls_url":"https://api.github.com/repos/Polymer/lit-html/pulls{/number}","milestones_url":"https://api.github.com/repos/Polymer/lit-html/milestones{/number}","notifications_url":"https://api.github.com/repos/Polymer/lit-html/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Polymer/lit-html/labels{/name}","releases_url":"https://api.github.com/repos/Polymer/lit-html/releases{/id}","deployments_url":"https://api.github.com/repos/Polymer/lit-html/deployments","created_at":"2017-06-29T16:27:16Z","updated_at":"2018-10-31T19:14:27Z","pushed_at":"2018-10-31T20:28:29Z","git_url":"git://github.com/Polymer/lit-html.git","ssh_url":"git@github.com:Polymer/lit-html.git","clone_url":"https://github.com/Polymer/lit-html.git","svn_url":"https://github.com/Polymer/lit-html","homepage":"https://polymer.github.io/lit-html/","size":1821,"stargazers_count":3198,"watchers_count":3198,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":186,"mirror_url":null,"archived":false,"open_issues_count":96,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":186,"open_issues":96,"watchers":3198,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Polymer/lit-html/pulls/555"},"html":{"href":"https://github.com/Polymer/lit-html/pull/555"},"issue":{"href":"https://api.github.com/repos/Polymer/lit-html/issues/555"},"comments":{"href":"https://api.github.com/repos/Polymer/lit-html/issues/555/comments"},"review_comments":{"href":"https://api.github.com/repos/Polymer/lit-html/pulls/555/comments"},"review_comment":{"href":"https://api.github.com/repos/Polymer/lit-html/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Polymer/lit-html/pulls/555/commits"},"statuses":{"href":"https://api.github.com/repos/Polymer/lit-html/statuses/ac8f1ac8a17491951f53d0b89cda6e5619d3067a"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"justinfagnani"}}