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

Reset history.current on destroy app #3294

Closed
nightnei opened this issue Aug 13, 2020 · 2 comments · Fixed by #3298
Closed

Reset history.current on destroy app #3294

nightnei opened this issue Aug 13, 2020 · 2 comments · Fixed by #3298
Labels
discussion feature request micro frontends Features to handle micro frontends

Comments

@nightnei
Copy link

nightnei commented Aug 13, 2020

Version

3.3.4

Reproduction link

https://jsfiddle.net/NightNei/5bv7co0u/10/

Steps to reproduce

1) Open "Reproduction link" -> OK - beforeResolve handler is run
2) Click "foo" btn -> OK - beforeResolve handler is run
3) Click "home" btn -> OK - beforeResolve handler is run
4) Click "destroy" btn -> OK - app destroyed
5) Click "start" btn -> FAIL - app started, but beforeResolve handler isn't run

What is expected?

beforeResolve is always run on start app

What is actually happening?

beforeResolve isn't run on restarting app


I am a maintainer of "Isomorphic Layout Composer" - Micro-frontends library( https://github.com/namecheap/ilc ).
And we have faced the problem of remounting Vue apps - when we render the same app second time, it will ignore running of beforeHooks.

Since on restart app history.current.matched contains last instance of route component so this condition:

isSameRoute(route, current) &&
returns true and router.beforeHooks are ignored.
On Destroy app we should reset history.current to default value(START).

@nightnei nightnei changed the title Reset cached components on destroy app Reset history.current on destroy app Aug 14, 2020
@posva posva added discussion feature request micro frontends Features to handle micro frontends labels Aug 14, 2020
@posva
Copy link
Member

posva commented Aug 15, 2020

I remember @joeldenning proposing something similar but I might be wrong. This seems reasonable to do when the last app is destroyed (set the location to START)

@joeldenning
Copy link
Contributor

I agree - my recent pr changed things so that the popstate and hashchange listeners are cleaned up when the last vue app is destroyed, but it didn't change it so that the history entries would be cleaned up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion feature request micro frontends Features to handle micro frontends
Projects
None yet
3 participants