{"action":"created","comment":{"url":"https://api.github.com/repos/hyperapp/router/pulls/comments/145648435","pull_request_review_id":70476861,"id":145648435,"diff_hunk":"@@ -1,72 +1,64 @@\n-export function router(options) {\n-  return function(emit) {\n-    return {\n-      state: {\n-        router: {}\n-      },\n-      actions: {\n-        router: {\n-          set: function(state, actions, data) {\n-            return {\n-              router: data\n-            }\n-          },\n-          go: function(state, actions, path) {\n-            if (location.pathname + location.search !== path) {\n-              history.pushState({}, \"\", path)\n-              actions.router.set({\n-                path: path\n-              })\n-            }\n-          }\n-        }\n-      },\n-      events: {\n-        load: function(state, actions) {\n-          addEventListener(\"popstate\", function() {\n-            actions.router.set({})\n-          })\n-        },\n-        render: function(state, actions, view) {\n-          return view[\n-            (state.router.index >= 0\n-              ? state\n-              : actions.router.set(\n-                  emit(\"route\", match(location.pathname, view))\n-                )).router.index\n-          ][1]\n-        }\n+import { h } from 'hyperapp'\n+\n+// router module\n+export const router = {\n+  actions: {\n+    set: function (state, actions, data) {\n+      return data\n+    },\n+    go: function (state, actions, path) {\n+      if (location.pathname + location.search !== path) {\n+        history.pushState({}, '', path)\n+        actions.set({ path: path })\n       }\n     }\n+  },\n+  init(state, actions) {\n+    window.addEventListener('popstate', function () {\n+      actions.set({})\n+    })\n   }\n }\n \n-function match(pathname, routes) {\n+// Router component\n+export function Router(props, children) {\n+  const m = match(location.pathname, children)","path":"src/router.js","position":64,"original_position":64,"commit_id":"42d3b2ad8855a148ac5f77b9548f54f50a38fd6a","original_commit_id":"42d3b2ad8855a148ac5f77b9548f54f50a38fd6a","user":{"login":"speier","id":415836,"avatar_url":"https://avatars3.githubusercontent.com/u/415836?v=4","gravatar_id":"","url":"https://api.github.com/users/speier","html_url":"https://github.com/speier","followers_url":"https://api.github.com/users/speier/followers","following_url":"https://api.github.com/users/speier/following{/other_user}","gists_url":"https://api.github.com/users/speier/gists{/gist_id}","starred_url":"https://api.github.com/users/speier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/speier/subscriptions","organizations_url":"https://api.github.com/users/speier/orgs","repos_url":"https://api.github.com/users/speier/repos","events_url":"https://api.github.com/users/speier/events{/privacy}","received_events_url":"https://api.github.com/users/speier/received_events","type":"User","site_admin":false},"body":"👍 ","created_at":"2017-10-19T09:41:27Z","updated_at":"2017-10-19T09:41:27Z","html_url":"https://github.com/hyperapp/router/pull/23#discussion_r145648435","pull_request_url":"https://api.github.com/repos/hyperapp/router/pulls/23","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/hyperapp/router/pulls/comments/145648435"},"html":{"href":"https://github.com/hyperapp/router/pull/23#discussion_r145648435"},"pull_request":{"href":"https://api.github.com/repos/hyperapp/router/pulls/23"}},"in_reply_to_id":145643736},"pull_request":{"url":"https://api.github.com/repos/hyperapp/router/pulls/23","id":147491660,"html_url":"https://github.com/hyperapp/router/pull/23","diff_url":"https://github.com/hyperapp/router/pull/23.diff","patch_url":"https://github.com/hyperapp/router/pull/23.patch","issue_url":"https://api.github.com/repos/hyperapp/router/issues/23","number":23,"state":"open","locked":false,"title":"Component Router","user":{"login":"speier","id":415836,"avatar_url":"https://avatars3.githubusercontent.com/u/415836?v=4","gravatar_id":"","url":"https://api.github.com/users/speier","html_url":"https://github.com/speier","followers_url":"https://api.github.com/users/speier/followers","following_url":"https://api.github.com/users/speier/following{/other_user}","gists_url":"https://api.github.com/users/speier/gists{/gist_id}","starred_url":"https://api.github.com/users/speier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/speier/subscriptions","organizations_url":"https://api.github.com/users/speier/orgs","repos_url":"https://api.github.com/users/speier/repos","events_url":"https://api.github.com/users/speier/events{/privacy}","received_events_url":"https://api.github.com/users/speier/received_events","type":"User","site_admin":false},"body":"Basic component router implementation.\r\n\r\n```jsx\r\nimport { h, app } from 'hyperapp';\r\nimport { router, Router, Route } from '@hyperapp/router';\r\n\r\napp({\r\n  state: { ... },\r\n  actions: { ... },\r\n  view: (state, actions) => (\r\n    <Router state={state} actions={actions}>\r\n      <Route path=\"/\" component={Home} />\r\n      <Route path=\"/login\" component={Login} />\r\n      <Route path=\"/404\" component={NotFound} />\r\n    </Router>\r\n  ),\r\n  modules: { router }\r\n})\r\n```","created_at":"2017-10-19T08:11:25Z","updated_at":"2017-10-19T09:41:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fb73c7e44309ae0e17224f00716661886228df65","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/hyperapp/router/pulls/23/commits","review_comments_url":"https://api.github.com/repos/hyperapp/router/pulls/23/comments","review_comment_url":"https://api.github.com/repos/hyperapp/router/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hyperapp/router/issues/23/comments","statuses_url":"https://api.github.com/repos/hyperapp/router/statuses/42d3b2ad8855a148ac5f77b9548f54f50a38fd6a","head":{"label":"speier:component-router","ref":"component-router","sha":"42d3b2ad8855a148ac5f77b9548f54f50a38fd6a","user":{"login":"speier","id":415836,"avatar_url":"https://avatars3.githubusercontent.com/u/415836?v=4","gravatar_id":"","url":"https://api.github.com/users/speier","html_url":"https://github.com/speier","followers_url":"https://api.github.com/users/speier/followers","following_url":"https://api.github.com/users/speier/following{/other_user}","gists_url":"https://api.github.com/users/speier/gists{/gist_id}","starred_url":"https://api.github.com/users/speier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/speier/subscriptions","organizations_url":"https://api.github.com/users/speier/orgs","repos_url":"https://api.github.com/users/speier/repos","events_url":"https://api.github.com/users/speier/events{/privacy}","received_events_url":"https://api.github.com/users/speier/received_events","type":"User","site_admin":false},"repo":{"id":106135292,"name":"router","full_name":"speier/router","owner":{"login":"speier","id":415836,"avatar_url":"https://avatars3.githubusercontent.com/u/415836?v=4","gravatar_id":"","url":"https://api.github.com/users/speier","html_url":"https://github.com/speier","followers_url":"https://api.github.com/users/speier/followers","following_url":"https://api.github.com/users/speier/following{/other_user}","gists_url":"https://api.github.com/users/speier/gists{/gist_id}","starred_url":"https://api.github.com/users/speier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/speier/subscriptions","organizations_url":"https://api.github.com/users/speier/orgs","repos_url":"https://api.github.com/users/speier/repos","events_url":"https://api.github.com/users/speier/events{/privacy}","received_events_url":"https://api.github.com/users/speier/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/speier/router","description":"Utilities for routing client-side pages with Hyperapp.","fork":true,"url":"https://api.github.com/repos/speier/router","forks_url":"https://api.github.com/repos/speier/router/forks","keys_url":"https://api.github.com/repos/speier/router/keys{/key_id}","collaborators_url":"https://api.github.com/repos/speier/router/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/speier/router/teams","hooks_url":"https://api.github.com/repos/speier/router/hooks","issue_events_url":"https://api.github.com/repos/speier/router/issues/events{/number}","events_url":"https://api.github.com/repos/speier/router/events","assignees_url":"https://api.github.com/repos/speier/router/assignees{/user}","branches_url":"https://api.github.com/repos/speier/router/branches{/branch}","tags_url":"https://api.github.com/repos/speier/router/tags","blobs_url":"https://api.github.com/repos/speier/router/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/speier/router/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/speier/router/git/refs{/sha}","trees_url":"https://api.github.com/repos/speier/router/git/trees{/sha}","statuses_url":"https://api.github.com/repos/speier/router/statuses/{sha}","languages_url":"https://api.github.com/repos/speier/router/languages","stargazers_url":"https://api.github.com/repos/speier/router/stargazers","contributors_url":"https://api.github.com/repos/speier/router/contributors","subscribers_url":"https://api.github.com/repos/speier/router/subscribers","subscription_url":"https://api.github.com/repos/speier/router/subscription","commits_url":"https://api.github.com/repos/speier/router/commits{/sha}","git_commits_url":"https://api.github.com/repos/speier/router/git/commits{/sha}","comments_url":"https://api.github.com/repos/speier/router/comments{/number}","issue_comment_url":"https://api.github.com/repos/speier/router/issues/comments{/number}","contents_url":"https://api.github.com/repos/speier/router/contents/{+path}","compare_url":"https://api.github.com/repos/speier/router/compare/{base}...{head}","merges_url":"https://api.github.com/repos/speier/router/merges","archive_url":"https://api.github.com/repos/speier/router/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/speier/router/downloads","issues_url":"https://api.github.com/repos/speier/router/issues{/number}","pulls_url":"https://api.github.com/repos/speier/router/pulls{/number}","milestones_url":"https://api.github.com/repos/speier/router/milestones{/number}","notifications_url":"https://api.github.com/repos/speier/router/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/speier/router/labels{/name}","releases_url":"https://api.github.com/repos/speier/router/releases{/id}","deployments_url":"https://api.github.com/repos/speier/router/deployments","created_at":"2017-10-07T22:41:31Z","updated_at":"2017-10-07T22:41:32Z","pushed_at":"2017-10-19T08:10:40Z","git_url":"git://github.com/speier/router.git","ssh_url":"git@github.com:speier/router.git","clone_url":"https://github.com/speier/router.git","svn_url":"https://github.com/speier/router","homepage":"","size":38,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hyperapp:master","ref":"master","sha":"abe55f3dc5ea80af2b47cd33baffdf99203c0a63","user":{"login":"hyperapp","id":25238911,"avatar_url":"https://avatars2.githubusercontent.com/u/25238911?v=4","gravatar_id":"","url":"https://api.github.com/users/hyperapp","html_url":"https://github.com/hyperapp","followers_url":"https://api.github.com/users/hyperapp/followers","following_url":"https://api.github.com/users/hyperapp/following{/other_user}","gists_url":"https://api.github.com/users/hyperapp/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperapp/subscriptions","organizations_url":"https://api.github.com/users/hyperapp/orgs","repos_url":"https://api.github.com/users/hyperapp/repos","events_url":"https://api.github.com/users/hyperapp/events{/privacy}","received_events_url":"https://api.github.com/users/hyperapp/received_events","type":"Organization","site_admin":false},"repo":{"id":33520773,"name":"router","full_name":"hyperapp/router","owner":{"login":"hyperapp","id":25238911,"avatar_url":"https://avatars2.githubusercontent.com/u/25238911?v=4","gravatar_id":"","url":"https://api.github.com/users/hyperapp","html_url":"https://github.com/hyperapp","followers_url":"https://api.github.com/users/hyperapp/followers","following_url":"https://api.github.com/users/hyperapp/following{/other_user}","gists_url":"https://api.github.com/users/hyperapp/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperapp/subscriptions","organizations_url":"https://api.github.com/users/hyperapp/orgs","repos_url":"https://api.github.com/users/hyperapp/repos","events_url":"https://api.github.com/users/hyperapp/events{/privacy}","received_events_url":"https://api.github.com/users/hyperapp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hyperapp/router","description":"Utilities for routing client-side pages with Hyperapp.","fork":false,"url":"https://api.github.com/repos/hyperapp/router","forks_url":"https://api.github.com/repos/hyperapp/router/forks","keys_url":"https://api.github.com/repos/hyperapp/router/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hyperapp/router/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hyperapp/router/teams","hooks_url":"https://api.github.com/repos/hyperapp/router/hooks","issue_events_url":"https://api.github.com/repos/hyperapp/router/issues/events{/number}","events_url":"https://api.github.com/repos/hyperapp/router/events","assignees_url":"https://api.github.com/repos/hyperapp/router/assignees{/user}","branches_url":"https://api.github.com/repos/hyperapp/router/branches{/branch}","tags_url":"https://api.github.com/repos/hyperapp/router/tags","blobs_url":"https://api.github.com/repos/hyperapp/router/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hyperapp/router/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hyperapp/router/git/refs{/sha}","trees_url":"https://api.github.com/repos/hyperapp/router/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hyperapp/router/statuses/{sha}","languages_url":"https://api.github.com/repos/hyperapp/router/languages","stargazers_url":"https://api.github.com/repos/hyperapp/router/stargazers","contributors_url":"https://api.github.com/repos/hyperapp/router/contributors","subscribers_url":"https://api.github.com/repos/hyperapp/router/subscribers","subscription_url":"https://api.github.com/repos/hyperapp/router/subscription","commits_url":"https://api.github.com/repos/hyperapp/router/commits{/sha}","git_commits_url":"https://api.github.com/repos/hyperapp/router/git/commits{/sha}","comments_url":"https://api.github.com/repos/hyperapp/router/comments{/number}","issue_comment_url":"https://api.github.com/repos/hyperapp/router/issues/comments{/number}","contents_url":"https://api.github.com/repos/hyperapp/router/contents/{+path}","compare_url":"https://api.github.com/repos/hyperapp/router/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hyperapp/router/merges","archive_url":"https://api.github.com/repos/hyperapp/router/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hyperapp/router/downloads","issues_url":"https://api.github.com/repos/hyperapp/router/issues{/number}","pulls_url":"https://api.github.com/repos/hyperapp/router/pulls{/number}","milestones_url":"https://api.github.com/repos/hyperapp/router/milestones{/number}","notifications_url":"https://api.github.com/repos/hyperapp/router/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hyperapp/router/labels{/name}","releases_url":"https://api.github.com/repos/hyperapp/router/releases{/id}","deployments_url":"https://api.github.com/repos/hyperapp/router/deployments","created_at":"2015-04-07T03:51:44Z","updated_at":"2017-10-18T10:50:53Z","pushed_at":"2017-10-19T08:11:26Z","git_url":"git://github.com/hyperapp/router.git","ssh_url":"git@github.com:hyperapp/router.git","clone_url":"https://github.com/hyperapp/router.git","svn_url":"https://github.com/hyperapp/router","homepage":"","size":33,"stargazers_count":61,"watchers_count":61,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":7,"forks":16,"open_issues":7,"watchers":61,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hyperapp/router/pulls/23"},"html":{"href":"https://github.com/hyperapp/router/pull/23"},"issue":{"href":"https://api.github.com/repos/hyperapp/router/issues/23"},"comments":{"href":"https://api.github.com/repos/hyperapp/router/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/hyperapp/router/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/hyperapp/router/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hyperapp/router/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/hyperapp/router/statuses/42d3b2ad8855a148ac5f77b9548f54f50a38fd6a"}},"author_association":"NONE"}}
{"actor":{"display_login":"speier"}}