{"action":"created","comment":{"url":"https://api.github.com/repos/conveyal/scenario-editor/pulls/comments/90404554","pull_request_review_id":10922013,"id":90404554,"diff_hunk":"@@ -65,15 +62,24 @@ async function createInstanceAndPutGrids (grids) {\n   return browsochrones\n }\n \n-/** Set the grids being used, in the format [{name, grid}...] */\n-export function setGrids (newGrids) {\n-  assert(instances.size === 0, 'Grids cannot be set after Browsochrones instances have been created.')\n-\n-  grids = newGrids\n-  processedGrids = new Map()\n+/** Ensure a grid has been loaded */\n+async function ensureGridLoaded (projectId, indicator) {\n+  if (!processedGrids.has(indicator)) {\n+    const grid = await authenticatedFetch(`/api/grid/${projectId}/${indicator}`)\n+      .then(res => res.arrayBuffer())\n+\n+    // put it in all instances\n+    const promises = []\n+    // Map does not have .map or .forEach\n+    for (const [, instance] of instances) {\n+      promises.push(instance.browsochrones.putGrid(indicator, grid))","path":"lib/utils/browsochrones.js","position":32,"original_position":32,"commit_id":"87614f1d29d948beb029f5edf5767ed2942af0f5","original_commit_id":"87614f1d29d948beb029f5edf5767ed2942af0f5","user":{"login":"trevorgerhardt","id":776780,"avatar_url":"https://avatars.githubusercontent.com/u/776780?v=3","gravatar_id":"","url":"https://api.github.com/users/trevorgerhardt","html_url":"https://github.com/trevorgerhardt","followers_url":"https://api.github.com/users/trevorgerhardt/followers","following_url":"https://api.github.com/users/trevorgerhardt/following{/other_user}","gists_url":"https://api.github.com/users/trevorgerhardt/gists{/gist_id}","starred_url":"https://api.github.com/users/trevorgerhardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trevorgerhardt/subscriptions","organizations_url":"https://api.github.com/users/trevorgerhardt/orgs","repos_url":"https://api.github.com/users/trevorgerhardt/repos","events_url":"https://api.github.com/users/trevorgerhardt/events{/privacy}","received_events_url":"https://api.github.com/users/trevorgerhardt/received_events","type":"User","site_admin":false},"body":"You can await directly here.\r\n\r\n```js\r\nfor (const [, instance] of instances) {\r\n  await instance.browsochrones.putGrid(indicator, grid)\r\n}\r\n```\r\n\r\nI would use `Promise.all` in this situation if you there was a possibility of a significant speed up from doing them asynchronously, like fetching external data. ","created_at":"2016-12-01T08:55:22Z","updated_at":"2016-12-01T08:55:22Z","html_url":"https://github.com/conveyal/scenario-editor/pull/199#discussion_r90404554","pull_request_url":"https://api.github.com/repos/conveyal/scenario-editor/pulls/199","_links":{"self":{"href":"https://api.github.com/repos/conveyal/scenario-editor/pulls/comments/90404554"},"html":{"href":"https://github.com/conveyal/scenario-editor/pull/199#discussion_r90404554"},"pull_request":{"href":"https://api.github.com/repos/conveyal/scenario-editor/pulls/199"}}},"pull_request":{"url":"https://api.github.com/repos/conveyal/scenario-editor/pulls/199","id":95922802,"html_url":"https://github.com/conveyal/scenario-editor/pull/199","diff_url":"https://github.com/conveyal/scenario-editor/pull/199.diff","patch_url":"https://github.com/conveyal/scenario-editor/pull/199.patch","issue_url":"https://api.github.com/repos/conveyal/scenario-editor/issues/199","number":199,"state":"open","locked":false,"title":"feat(analysis): Lazy-load grids, rather than loading them all up front.","user":{"login":"mattwigway","id":566958,"avatar_url":"https://avatars.githubusercontent.com/u/566958?v=3","gravatar_id":"","url":"https://api.github.com/users/mattwigway","html_url":"https://github.com/mattwigway","followers_url":"https://api.github.com/users/mattwigway/followers","following_url":"https://api.github.com/users/mattwigway/following{/other_user}","gists_url":"https://api.github.com/users/mattwigway/gists{/gist_id}","starred_url":"https://api.github.com/users/mattwigway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattwigway/subscriptions","organizations_url":"https://api.github.com/users/mattwigway/orgs","repos_url":"https://api.github.com/users/mattwigway/repos","events_url":"https://api.github.com/users/mattwigway/events{/privacy}","received_events_url":"https://api.github.com/users/mattwigway/received_events","type":"User","site_admin":false},"body":"Grids used to be loaded on project load. Since most were never used, this was a huge waste of memory\r\n\r\nin larger projects.","created_at":"2016-11-30T16:17:45Z","updated_at":"2016-12-01T08:55:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2ae4144513156b1882d8b3f1ecb9053d9b7f95a2","assignee":{"login":"trevorgerhardt","id":776780,"avatar_url":"https://avatars.githubusercontent.com/u/776780?v=3","gravatar_id":"","url":"https://api.github.com/users/trevorgerhardt","html_url":"https://github.com/trevorgerhardt","followers_url":"https://api.github.com/users/trevorgerhardt/followers","following_url":"https://api.github.com/users/trevorgerhardt/following{/other_user}","gists_url":"https://api.github.com/users/trevorgerhardt/gists{/gist_id}","starred_url":"https://api.github.com/users/trevorgerhardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trevorgerhardt/subscriptions","organizations_url":"https://api.github.com/users/trevorgerhardt/orgs","repos_url":"https://api.github.com/users/trevorgerhardt/repos","events_url":"https://api.github.com/users/trevorgerhardt/events{/privacy}","received_events_url":"https://api.github.com/users/trevorgerhardt/received_events","type":"User","site_admin":false},"assignees":[{"login":"trevorgerhardt","id":776780,"avatar_url":"https://avatars.githubusercontent.com/u/776780?v=3","gravatar_id":"","url":"https://api.github.com/users/trevorgerhardt","html_url":"https://github.com/trevorgerhardt","followers_url":"https://api.github.com/users/trevorgerhardt/followers","following_url":"https://api.github.com/users/trevorgerhardt/following{/other_user}","gists_url":"https://api.github.com/users/trevorgerhardt/gists{/gist_id}","starred_url":"https://api.github.com/users/trevorgerhardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trevorgerhardt/subscriptions","organizations_url":"https://api.github.com/users/trevorgerhardt/orgs","repos_url":"https://api.github.com/users/trevorgerhardt/repos","events_url":"https://api.github.com/users/trevorgerhardt/events{/privacy}","received_events_url":"https://api.github.com/users/trevorgerhardt/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/conveyal/scenario-editor/pulls/199/commits","review_comments_url":"https://api.github.com/repos/conveyal/scenario-editor/pulls/199/comments","review_comment_url":"https://api.github.com/repos/conveyal/scenario-editor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/conveyal/scenario-editor/issues/199/comments","statuses_url":"https://api.github.com/repos/conveyal/scenario-editor/statuses/87614f1d29d948beb029f5edf5767ed2942af0f5","head":{"label":"conveyal:lazy-load-grids","ref":"lazy-load-grids","sha":"87614f1d29d948beb029f5edf5767ed2942af0f5","user":{"login":"conveyal","id":3592637,"avatar_url":"https://avatars.githubusercontent.com/u/3592637?v=3","gravatar_id":"","url":"https://api.github.com/users/conveyal","html_url":"https://github.com/conveyal","followers_url":"https://api.github.com/users/conveyal/followers","following_url":"https://api.github.com/users/conveyal/following{/other_user}","gists_url":"https://api.github.com/users/conveyal/gists{/gist_id}","starred_url":"https://api.github.com/users/conveyal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conveyal/subscriptions","organizations_url":"https://api.github.com/users/conveyal/orgs","repos_url":"https://api.github.com/users/conveyal/repos","events_url":"https://api.github.com/users/conveyal/events{/privacy}","received_events_url":"https://api.github.com/users/conveyal/received_events","type":"Organization","site_admin":false},"repo":{"id":49971505,"name":"scenario-editor","full_name":"conveyal/scenario-editor","owner":{"login":"conveyal","id":3592637,"avatar_url":"https://avatars.githubusercontent.com/u/3592637?v=3","gravatar_id":"","url":"https://api.github.com/users/conveyal","html_url":"https://github.com/conveyal","followers_url":"https://api.github.com/users/conveyal/followers","following_url":"https://api.github.com/users/conveyal/following{/other_user}","gists_url":"https://api.github.com/users/conveyal/gists{/gist_id}","starred_url":"https://api.github.com/users/conveyal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conveyal/subscriptions","organizations_url":"https://api.github.com/users/conveyal/orgs","repos_url":"https://api.github.com/users/conveyal/repos","events_url":"https://api.github.com/users/conveyal/events{/privacy}","received_events_url":"https://api.github.com/users/conveyal/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/conveyal/scenario-editor","description":"Conveyal's frontend for editing transportation scenarios.","fork":false,"url":"https://api.github.com/repos/conveyal/scenario-editor","forks_url":"https://api.github.com/repos/conveyal/scenario-editor/forks","keys_url":"https://api.github.com/repos/conveyal/scenario-editor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/conveyal/scenario-editor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/conveyal/scenario-editor/teams","hooks_url":"https://api.github.com/repos/conveyal/scenario-editor/hooks","issue_events_url":"https://api.github.com/repos/conveyal/scenario-editor/issues/events{/number}","events_url":"https://api.github.com/repos/conveyal/scenario-editor/events","assignees_url":"https://api.github.com/repos/conveyal/scenario-editor/assignees{/user}","branches_url":"https://api.github.com/repos/conveyal/scenario-editor/branches{/branch}","tags_url":"https://api.github.com/repos/conveyal/scenario-editor/tags","blobs_url":"https://api.github.com/repos/conveyal/scenario-editor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/conveyal/scenario-editor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/conveyal/scenario-editor/git/refs{/sha}","trees_url":"https://api.github.com/repos/conveyal/scenario-editor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/conveyal/scenario-editor/statuses/{sha}","languages_url":"https://api.github.com/repos/conveyal/scenario-editor/languages","stargazers_url":"https://api.github.com/repos/conveyal/scenario-editor/stargazers","contributors_url":"https://api.github.com/repos/conveyal/scenario-editor/contributors","subscribers_url":"https://api.github.com/repos/conveyal/scenario-editor/subscribers","subscription_url":"https://api.github.com/repos/conveyal/scenario-editor/subscription","commits_url":"https://api.github.com/repos/conveyal/scenario-editor/commits{/sha}","git_commits_url":"https://api.github.com/repos/conveyal/scenario-editor/git/commits{/sha}","comments_url":"https://api.github.com/repos/conveyal/scenario-editor/comments{/number}","issue_comment_url":"https://api.github.com/repos/conveyal/scenario-editor/issues/comments{/number}","contents_url":"https://api.github.com/repos/conveyal/scenario-editor/contents/{+path}","compare_url":"https://api.github.com/repos/conveyal/scenario-editor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/conveyal/scenario-editor/merges","archive_url":"https://api.github.com/repos/conveyal/scenario-editor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/conveyal/scenario-editor/downloads","issues_url":"https://api.github.com/repos/conveyal/scenario-editor/issues{/number}","pulls_url":"https://api.github.com/repos/conveyal/scenario-editor/pulls{/number}","milestones_url":"https://api.github.com/repos/conveyal/scenario-editor/milestones{/number}","notifications_url":"https://api.github.com/repos/conveyal/scenario-editor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/conveyal/scenario-editor/labels{/name}","releases_url":"https://api.github.com/repos/conveyal/scenario-editor/releases{/id}","deployments_url":"https://api.github.com/repos/conveyal/scenario-editor/deployments","created_at":"2016-01-19T17:53:13Z","updated_at":"2016-11-27T21:10:32Z","pushed_at":"2016-11-30T21:17:21Z","git_url":"git://github.com/conveyal/scenario-editor.git","ssh_url":"git@github.com:conveyal/scenario-editor.git","clone_url":"https://github.com/conveyal/scenario-editor.git","svn_url":"https://github.com/conveyal/scenario-editor","homepage":null,"size":49234,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":50,"forks":3,"open_issues":50,"watchers":6,"default_branch":"dev"}},"base":{"label":"conveyal:dev","ref":"dev","sha":"8fab44493c9c3cf88edaa531c1de9e6333c9c424","user":{"login":"conveyal","id":3592637,"avatar_url":"https://avatars.githubusercontent.com/u/3592637?v=3","gravatar_id":"","url":"https://api.github.com/users/conveyal","html_url":"https://github.com/conveyal","followers_url":"https://api.github.com/users/conveyal/followers","following_url":"https://api.github.com/users/conveyal/following{/other_user}","gists_url":"https://api.github.com/users/conveyal/gists{/gist_id}","starred_url":"https://api.github.com/users/conveyal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conveyal/subscriptions","organizations_url":"https://api.github.com/users/conveyal/orgs","repos_url":"https://api.github.com/users/conveyal/repos","events_url":"https://api.github.com/users/conveyal/events{/privacy}","received_events_url":"https://api.github.com/users/conveyal/received_events","type":"Organization","site_admin":false},"repo":{"id":49971505,"name":"scenario-editor","full_name":"conveyal/scenario-editor","owner":{"login":"conveyal","id":3592637,"avatar_url":"https://avatars.githubusercontent.com/u/3592637?v=3","gravatar_id":"","url":"https://api.github.com/users/conveyal","html_url":"https://github.com/conveyal","followers_url":"https://api.github.com/users/conveyal/followers","following_url":"https://api.github.com/users/conveyal/following{/other_user}","gists_url":"https://api.github.com/users/conveyal/gists{/gist_id}","starred_url":"https://api.github.com/users/conveyal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conveyal/subscriptions","organizations_url":"https://api.github.com/users/conveyal/orgs","repos_url":"https://api.github.com/users/conveyal/repos","events_url":"https://api.github.com/users/conveyal/events{/privacy}","received_events_url":"https://api.github.com/users/conveyal/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/conveyal/scenario-editor","description":"Conveyal's frontend for editing transportation scenarios.","fork":false,"url":"https://api.github.com/repos/conveyal/scenario-editor","forks_url":"https://api.github.com/repos/conveyal/scenario-editor/forks","keys_url":"https://api.github.com/repos/conveyal/scenario-editor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/conveyal/scenario-editor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/conveyal/scenario-editor/teams","hooks_url":"https://api.github.com/repos/conveyal/scenario-editor/hooks","issue_events_url":"https://api.github.com/repos/conveyal/scenario-editor/issues/events{/number}","events_url":"https://api.github.com/repos/conveyal/scenario-editor/events","assignees_url":"https://api.github.com/repos/conveyal/scenario-editor/assignees{/user}","branches_url":"https://api.github.com/repos/conveyal/scenario-editor/branches{/branch}","tags_url":"https://api.github.com/repos/conveyal/scenario-editor/tags","blobs_url":"https://api.github.com/repos/conveyal/scenario-editor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/conveyal/scenario-editor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/conveyal/scenario-editor/git/refs{/sha}","trees_url":"https://api.github.com/repos/conveyal/scenario-editor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/conveyal/scenario-editor/statuses/{sha}","languages_url":"https://api.github.com/repos/conveyal/scenario-editor/languages","stargazers_url":"https://api.github.com/repos/conveyal/scenario-editor/stargazers","contributors_url":"https://api.github.com/repos/conveyal/scenario-editor/contributors","subscribers_url":"https://api.github.com/repos/conveyal/scenario-editor/subscribers","subscription_url":"https://api.github.com/repos/conveyal/scenario-editor/subscription","commits_url":"https://api.github.com/repos/conveyal/scenario-editor/commits{/sha}","git_commits_url":"https://api.github.com/repos/conveyal/scenario-editor/git/commits{/sha}","comments_url":"https://api.github.com/repos/conveyal/scenario-editor/comments{/number}","issue_comment_url":"https://api.github.com/repos/conveyal/scenario-editor/issues/comments{/number}","contents_url":"https://api.github.com/repos/conveyal/scenario-editor/contents/{+path}","compare_url":"https://api.github.com/repos/conveyal/scenario-editor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/conveyal/scenario-editor/merges","archive_url":"https://api.github.com/repos/conveyal/scenario-editor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/conveyal/scenario-editor/downloads","issues_url":"https://api.github.com/repos/conveyal/scenario-editor/issues{/number}","pulls_url":"https://api.github.com/repos/conveyal/scenario-editor/pulls{/number}","milestones_url":"https://api.github.com/repos/conveyal/scenario-editor/milestones{/number}","notifications_url":"https://api.github.com/repos/conveyal/scenario-editor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/conveyal/scenario-editor/labels{/name}","releases_url":"https://api.github.com/repos/conveyal/scenario-editor/releases{/id}","deployments_url":"https://api.github.com/repos/conveyal/scenario-editor/deployments","created_at":"2016-01-19T17:53:13Z","updated_at":"2016-11-27T21:10:32Z","pushed_at":"2016-11-30T21:17:21Z","git_url":"git://github.com/conveyal/scenario-editor.git","ssh_url":"git@github.com:conveyal/scenario-editor.git","clone_url":"https://github.com/conveyal/scenario-editor.git","svn_url":"https://github.com/conveyal/scenario-editor","homepage":null,"size":49234,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":50,"forks":3,"open_issues":50,"watchers":6,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/conveyal/scenario-editor/pulls/199"},"html":{"href":"https://github.com/conveyal/scenario-editor/pull/199"},"issue":{"href":"https://api.github.com/repos/conveyal/scenario-editor/issues/199"},"comments":{"href":"https://api.github.com/repos/conveyal/scenario-editor/issues/199/comments"},"review_comments":{"href":"https://api.github.com/repos/conveyal/scenario-editor/pulls/199/comments"},"review_comment":{"href":"https://api.github.com/repos/conveyal/scenario-editor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/conveyal/scenario-editor/pulls/199/commits"},"statuses":{"href":"https://api.github.com/repos/conveyal/scenario-editor/statuses/87614f1d29d948beb029f5edf5767ed2942af0f5"}}}}
{"actor":{"display_login":"trevorgerhardt"}}