{"action":"created","issue":{"url":"https://api.github.com/repos/angular/router/issues/396","repository_url":"https://api.github.com/repos/angular/router","labels_url":"https://api.github.com/repos/angular/router/issues/396/labels{/name}","comments_url":"https://api.github.com/repos/angular/router/issues/396/comments","events_url":"https://api.github.com/repos/angular/router/issues/396/events","html_url":"https://github.com/angular/router/issues/396","id":132758332,"number":396,"title":"Which is the use of routerCanReuse in angular2?","user":{"login":"giorgiofran","id":4466457,"avatar_url":"https://avatars.githubusercontent.com/u/4466457?v=3","gravatar_id":"","url":"https://api.github.com/users/giorgiofran","html_url":"https://github.com/giorgiofran","followers_url":"https://api.github.com/users/giorgiofran/followers","following_url":"https://api.github.com/users/giorgiofran/following{/other_user}","gists_url":"https://api.github.com/users/giorgiofran/gists{/gist_id}","starred_url":"https://api.github.com/users/giorgiofran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giorgiofran/subscriptions","organizations_url":"https://api.github.com/users/giorgiofran/orgs","repos_url":"https://api.github.com/users/giorgiofran/repos","events_url":"https://api.github.com/users/giorgiofran/events{/privacy}","received_events_url":"https://api.github.com/users/giorgiofran/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-10T17:00:13Z","updated_at":"2016-02-10T20:36:13Z","closed_at":null,"body":"\r\n\r\nI'm using angular2 (beta.3) with dart.\r\nI'trying to understand which is the logic behind the routerCanReuse method.\r\n\r\nWhat I have understood googling and doing some tests on a simple example, is that routerCanReuse is called when the same route as the active one is invoked.\r\n\r\nIn my component called by the route invocation, I have a variable (only for test) that is incremented in any method call.\r\n\r\nWhat I could see is that if I set a true return value in routerCanDeactivate(), the variable is resetted, while if I return false in routerCanReuse, the variable is not resetted,even if the canActivate function is called immediately after.\r\n\r\nIn my tests, canReuse is called even if the route parameters are the same.\r\nI'm confused because it seem to me that canReuse and canDeactivate, when I route to the same component, have the same meaning.\r\n\r\nObviously it is not like that and I'm missing something.\r\n\r\nIs there anyone that can explain me how these methods work?\r\n"},"comment":{"url":"https://api.github.com/repos/angular/router/issues/comments/182573232","html_url":"https://github.com/angular/router/issues/396#issuecomment-182573232","issue_url":"https://api.github.com/repos/angular/router/issues/396","id":182573232,"user":{"login":"ArniDzhan","id":3141905,"avatar_url":"https://avatars.githubusercontent.com/u/3141905?v=3","gravatar_id":"","url":"https://api.github.com/users/ArniDzhan","html_url":"https://github.com/ArniDzhan","followers_url":"https://api.github.com/users/ArniDzhan/followers","following_url":"https://api.github.com/users/ArniDzhan/following{/other_user}","gists_url":"https://api.github.com/users/ArniDzhan/gists{/gist_id}","starred_url":"https://api.github.com/users/ArniDzhan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArniDzhan/subscriptions","organizations_url":"https://api.github.com/users/ArniDzhan/orgs","repos_url":"https://api.github.com/users/ArniDzhan/repos","events_url":"https://api.github.com/users/ArniDzhan/events{/privacy}","received_events_url":"https://api.github.com/users/ArniDzhan/received_events","type":"User","site_admin":false},"created_at":"2016-02-10T20:36:13Z","updated_at":"2016-02-10T20:36:13Z","body":"you should ask your router related questions on angular/angular\r\nbut to answer your question, routerCanReuse is triggered on every call to component. There is another hook routerOnReuse which is called only if you try to load the same component which is already loaded and if routerCanReuse returns true.\r\nHope that helps\r\n"}}