{"action":"opened","issue":{"url":"https://api.github.com/repos/MithrilJS/mithril.js/issues/2059","repository_url":"https://api.github.com/repos/MithrilJS/mithril.js","labels_url":"https://api.github.com/repos/MithrilJS/mithril.js/issues/2059/labels{/name}","comments_url":"https://api.github.com/repos/MithrilJS/mithril.js/issues/2059/comments","events_url":"https://api.github.com/repos/MithrilJS/mithril.js/issues/2059/events","html_url":"https://github.com/MithrilJS/mithril.js/issues/2059","id":284462694,"number":2059,"title":"How to do redirection with m.route correctly?","user":{"login":"odzhychko","id":13496841,"avatar_url":"https://avatars1.githubusercontent.com/u/13496841?v=4","gravatar_id":"","url":"https://api.github.com/users/odzhychko","html_url":"https://github.com/odzhychko","followers_url":"https://api.github.com/users/odzhychko/followers","following_url":"https://api.github.com/users/odzhychko/following{/other_user}","gists_url":"https://api.github.com/users/odzhychko/gists{/gist_id}","starred_url":"https://api.github.com/users/odzhychko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odzhychko/subscriptions","organizations_url":"https://api.github.com/users/odzhychko/orgs","repos_url":"https://api.github.com/users/odzhychko/repos","events_url":"https://api.github.com/users/odzhychko/events{/privacy}","received_events_url":"https://api.github.com/users/odzhychko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-25T18:02:46Z","updated_at":"2017-12-25T18:02:46Z","closed_at":null,"author_association":"NONE","body":"For example I want my application to redirect automatically from `#!/c`  to `#!/b`.\r\n\r\nAt the first glance it works as expected by using `m.route.set` in the `view` method of a Component or in the `onmatch` method of a RouteResolver. Am I a using it as intended or are there other, more correct ways?\r\n\r\nHere is my example code: \r\n```\r\nconst menu = {\r\n  view: function() {\r\n    return m('nav', [\r\n    \tm('#', 'current route: ' + m.route.get()),\r\n      m('a[href=/a]', {oncreate: m.route.link}, 'a'),\r\n      m('a[href=/b]', {oncreate: m.route.link}, 'b'),\r\n      m('a[href=/c]', {oncreate: m.route.link}, 'c'),\r\n      m('a[href=/d]', {oncreate: m.route.link}, 'd')\r\n    ])\r\n  }\r\n}\r\n\r\nconst a = {\r\n  view: function() {\r\n    return [\r\n      m(menu),\r\n      m('#', 'page: a')\r\n    ];\r\n  }\r\n};\r\n\r\nconst b = {\r\n  view: function() {\r\n    return [\r\n      m(menu),\r\n      m('#', 'page: b')\r\n    ];\r\n  }\r\n};\r\n\r\nconst redirectToBWithComponent = {\r\n\tview: function() {\r\n  \tm.route.set('/b');\r\n  }\r\n};\r\n\r\nconst redirectToBWithRouteResolver = {\r\n\tonmatch: function() {\r\n  \tm.route.set('/b');\r\n  }\r\n};\r\n\r\n\r\nm.route(document.body, '/a', {\r\n    '/a': a,\r\n    '/b': b,\r\n    '/c': redirectToBWithComponent,\r\n    '/d': redirectToBWithRouteResolver\r\n})\r\n```\r\n[There](https://jsfiddle.net/7Lgpjysh/12/) is a live version of it."}}
{"actor":{"display_login":"odzhychko"}}