{"action":"created","issue":{"url":"https://api.github.com/repos/driftyco/ionic/issues/3909","labels_url":"https://api.github.com/repos/driftyco/ionic/issues/3909/labels{/name}","comments_url":"https://api.github.com/repos/driftyco/ionic/issues/3909/comments","events_url":"https://api.github.com/repos/driftyco/ionic/issues/3909/events","html_url":"https://github.com/driftyco/ionic/issues/3909","id":86601565,"number":3909,"title":"feat: cached states/nav-views and ui-router resolves","user":{"login":"RBLU","id":2692565,"avatar_url":"https://avatars.githubusercontent.com/u/2692565?v=3","gravatar_id":"","url":"https://api.github.com/users/RBLU","html_url":"https://github.com/RBLU","followers_url":"https://api.github.com/users/RBLU/followers","following_url":"https://api.github.com/users/RBLU/following{/other_user}","gists_url":"https://api.github.com/users/RBLU/gists{/gist_id}","starred_url":"https://api.github.com/users/RBLU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RBLU/subscriptions","organizations_url":"https://api.github.com/users/RBLU/orgs","repos_url":"https://api.github.com/users/RBLU/repos","events_url":"https://api.github.com/users/RBLU/events{/privacy}","received_events_url":"https://api.github.com/users/RBLU/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/driftyco/ionic/labels/needs%20reply","name":"needs reply","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-09T13:33:41Z","updated_at":"2015-06-11T19:01:56Z","closed_at":null,"body":"**Type**: <span ionic-type>feat</span>\r\n\r\n**Platform**: <span ionic-platform>all</span>  \r\n\r\n<span ionic-description>in ionic 1.0.0 when a ui-router state has `cache: true` (or also just the default value meaning cache: true):\r\n- resolves are executed again when I transition back to a previously cached state\r\n- but the result of these fresh resolves is not easily accessible (even though they can be retrieved by injecting $state and accessing `$state.$current.locals.resolve.then(function(resolves) {...`\r\n\r\nThis does not make sense to me, either we should not execute the resolves when we transition back to a cached state, or we should make the result of the fresh resolves easily available throught the enteringData of the $ionicView.enter event.\r\n\r\nSo I am unsure about the intended behaviour. \r\n\r\nFor the current behaviour (executing resolves upon transitioning into a cached state) I suggest to add the following line to ionicViewSwitcher.transition function: https://github.com/driftyco/ionic/blob/master/js/angular/service/viewSwitcher.js#L153-L154\r\n\r\n    enteringData.resolves = viewLocals:\r\n\r\nto provide acces to the fresh resolves.\r\n\r\nPlease advise whether this is a good idea, i will happily provide a PR</span>\r\n\r\n<span is-issue-template></span>\r\n"},"comment":{"url":"https://api.github.com/repos/driftyco/ionic/issues/comments/111240415","html_url":"https://github.com/driftyco/ionic/issues/3909#issuecomment-111240415","issue_url":"https://api.github.com/repos/driftyco/ionic/issues/3909","id":111240415,"user":{"login":"RBLU","id":2692565,"avatar_url":"https://avatars.githubusercontent.com/u/2692565?v=3","gravatar_id":"","url":"https://api.github.com/users/RBLU","html_url":"https://github.com/RBLU","followers_url":"https://api.github.com/users/RBLU/followers","following_url":"https://api.github.com/users/RBLU/following{/other_user}","gists_url":"https://api.github.com/users/RBLU/gists{/gist_id}","starred_url":"https://api.github.com/users/RBLU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RBLU/subscriptions","organizations_url":"https://api.github.com/users/RBLU/orgs","repos_url":"https://api.github.com/users/RBLU/repos","events_url":"https://api.github.com/users/RBLU/events{/privacy}","received_events_url":"https://api.github.com/users/RBLU/received_events","type":"User","site_admin":false},"created_at":"2015-06-11T19:01:56Z","updated_at":"2015-06-11T19:01:56Z","body":"see here: http://codepen.io/anon/pen/OVgQQx\r\n\r\nswitch between state 1 und state 2 several time and look at the JS console:\r\n\r\n- see how state 1 is cached (controller 1 is only executed once) \r\n- but resolve 1 is executed every time you enter state 1\r\n- there is currently no easy way to retrieve the result of this resolve\r\n\r\n(I don't understand why state 2 is not being cached in this codepen (controller 2 is executed every time), but that is a different issue)"}}