{"action":"created","issue":{"url":"https://api.github.com/repos/kirbyfan64/vuedart/issues/29","repository_url":"https://api.github.com/repos/kirbyfan64/vuedart","labels_url":"https://api.github.com/repos/kirbyfan64/vuedart/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/kirbyfan64/vuedart/issues/29/comments","events_url":"https://api.github.com/repos/kirbyfan64/vuedart/issues/29/events","html_url":"https://github.com/kirbyfan64/vuedart/issues/29","id":387533710,"node_id":"MDU6SXNzdWUzODc1MzM3MTA=","number":29,"title":"Router before/after hooks","user":{"login":"shane-lab","id":8008368,"node_id":"MDQ6VXNlcjgwMDgzNjg=","avatar_url":"https://avatars2.githubusercontent.com/u/8008368?v=4","gravatar_id":"","url":"https://api.github.com/users/shane-lab","html_url":"https://github.com/shane-lab","followers_url":"https://api.github.com/users/shane-lab/followers","following_url":"https://api.github.com/users/shane-lab/following{/other_user}","gists_url":"https://api.github.com/users/shane-lab/gists{/gist_id}","starred_url":"https://api.github.com/users/shane-lab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shane-lab/subscriptions","organizations_url":"https://api.github.com/users/shane-lab/orgs","repos_url":"https://api.github.com/users/shane-lab/repos","events_url":"https://api.github.com/users/shane-lab/events{/privacy}","received_events_url":"https://api.github.com/users/shane-lab/received_events","type":"User","site_admin":false},"labels":[{"id":679255336,"node_id":"MDU6TGFiZWw2NzkyNTUzMzY=","url":"https://api.github.com/repos/kirbyfan64/vuedart/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-05T00:01:19Z","updated_at":"2018-12-05T00:39:47Z","closed_at":null,"author_association":"NONE","body":"Hey, thanks for this library!\r\n\r\nI've just started with both Dart and Vue and thus I've now been using your VueDart for a few days. I'd like to add some progress indicator when switching routes. Unfortunately, an instance of VueRouter does not expose a method to set either `beforeHooks` or `afterHooks`. I've managed to hack in the following:\r\n\r\n```dart\r\n  final router = VueRouter(mode: VueRouterMode.history, routes: [\r\n    ...\r\n  ]);\r\n\r\n  // hacking in the router object\r\n  var hookable = (router.appOptions.entries.first.value as dynamic);\r\n  if (hookable != null) {\r\n    setProperty(hookable, 'beforeHooks', [\r\n      (dynamic to, dynamic from, Function next) {\r\n        if (to.name != null) {\r\n          NProgress.start();\r\n        }\r\n\r\n        next();\r\n      }\r\n    ]);\r\n\r\n    setProperty(hookable, 'afterHooks', [\r\n      (dynamic to, dynamic from) => NProgress.done()\r\n    ]);\r\n  }\r\n```\r\n\r\nThis doesn't directly work when compiling with `dart2js`, as these functions do not translate well to javascript.. \r\n\r\nI am wondering if there is any support planned to add router before/after hooks?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/kirbyfan64/vuedart/issues/comments/444313743","html_url":"https://github.com/kirbyfan64/vuedart/issues/29#issuecomment-444313743","issue_url":"https://api.github.com/repos/kirbyfan64/vuedart/issues/29","id":444313743,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NDMxMzc0Mw==","user":{"login":"kirbyfan64","id":1690697,"node_id":"MDQ6VXNlcjE2OTA2OTc=","avatar_url":"https://avatars1.githubusercontent.com/u/1690697?v=4","gravatar_id":"","url":"https://api.github.com/users/kirbyfan64","html_url":"https://github.com/kirbyfan64","followers_url":"https://api.github.com/users/kirbyfan64/followers","following_url":"https://api.github.com/users/kirbyfan64/following{/other_user}","gists_url":"https://api.github.com/users/kirbyfan64/gists{/gist_id}","starred_url":"https://api.github.com/users/kirbyfan64/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kirbyfan64/subscriptions","organizations_url":"https://api.github.com/users/kirbyfan64/orgs","repos_url":"https://api.github.com/users/kirbyfan64/repos","events_url":"https://api.github.com/users/kirbyfan64/events{/privacy}","received_events_url":"https://api.github.com/users/kirbyfan64/received_events","type":"User","site_admin":false},"created_at":"2018-12-05T00:39:47Z","updated_at":"2018-12-05T00:39:47Z","author_association":"OWNER","body":"Ah I forgot all about that...\n\nAs a workaround until then, you can create a class `class MyVueRoute<T extends VueComponentBase> extends VueRoute<T>`, then override `jsargs` to add the arguments to the returned JS object."}}
{"actor":{"display_login":"kirbyfan64"}}