Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 2: Components in history getting created newly every time while going back #7965

Closed
TheMohanraj opened this issue Apr 8, 2016 · 9 comments
Labels
area: router feature Issue that requests a new feature freq2: medium

Comments

@TheMohanraj
Copy link

In Angular 2 Tour of Heroes example,

  1. I'm moving from Top heroes to heroes detail page.
  2. Now from heroes detail page, I'm pressing back and It navigates back to top heroes page.
  3. Here I noticed that, top heroes page constructor was getting called again.

It seems to be very expensive, every time we land the page, It has to make numerous http calls.

@zoechi
Copy link
Contributor

zoechi commented Apr 8, 2016

What about creating a plunker as mentioned in the linked issue?

Does the component implement CanReuse

@TheMohanraj
Copy link
Author

Sure. Here is the link http://plnkr.co/edit/P7BsEws3sKGbhhNH0OVA?p=preview
Launch for preview, select a top hero and the go back

@zoechi
Copy link
Contributor

zoechi commented Apr 8, 2016

@CaptainCodeman
Copy link

CanReuse is not going to help you here IMO. You can't prevent the reloading of the component unless Angular 2 (or another router) introduces some sticky-state / component cache mechanism.

In the meantime, you could use the service to cache data to prevent it being re-requested although then people's expectation that going to the page will show the latest values may be tested - you need some mechanism to push or poll to changes.

@PareshMangukiya
Copy link

I am also facing same issue.

@vsavkin vsavkin added feature Issue that requests a new feature freq2: medium labels Oct 10, 2016
@PareshMangukiya
Copy link

when this issue has been resolved any ET?

@sintro
Copy link

sintro commented Nov 20, 2016

I think, this issue have the same theme as described here #7757
In a nutshell: there is must be the built-in solution of caching and reusing of every previously rendered (in one browser session) component. Ideally, it should be something like russian-doll caching (nested fragment/component caches), with checking for update of every showed component in background and rerendering it if new data was fetched.
This behaviour is called "Reactivity" in Meteor community (if I'm not mistaken), and heavily used in that framework out-of-box: you will see something immediately after any action, and after browser will get confirmation data from server, it will correct the DOM elements with actual data (if needed). Any "suggested" components is drawn from the cache or pre-written code.

@DzmitryShylovich
Copy link
Contributor

#13124 already merged
so this one can be closed @pkozlowski-opensource

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: router feature Issue that requests a new feature freq2: medium
Projects
None yet
Development

No branches or pull requests

9 participants