-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Allow pausing listeners at the history level #1270
Comments
Cant we expose |
The sub app will automatically call The reproduction is huge, can you remove all unnecessary packages? At the very least everything related to linting, formatting, CSS (you have both less and sass in there), TypeScript, and not having a mono repo would be better as well We could expose |
I remove unuse file, and push it. https://github.com/beiifeng/vue-router-next-report/blob/main/README.md It maybe here https://github.com/single-spa/single-spa/blob/master/src/navigation/navigation-events.js#L105 |
It looks like single-spa's error single-spa/single-spa#911 One way to resolve this error is expose history-listener api to let developers control listener manualy. |
It is a feature of single-spa, that it will fires PopStateEvent events when it wants to instruct all active applications to re-render. #1423 |
@beiifeng I still need you to remove all the dependencies I mentioned plus anything external or not necessary before I can take a look (e.g. no vue-class-component, qiankun, no babel, etc,) https://github.com/beiifeng/vue-router-next-report/blob/main/packages/main/package.json |
@posva hi posva, I try to simplify this reproduction, I remove many unnecessary dependencies but except You can see this repo, also you can see in codesandbox. one more thing, I have seen someone said it will behave normally if he use vue-router@3.x in qiankun, and i will try again with 3.x. |
hmm, still not clear what is the best direction here. So far, I think adding a new const history = createWebHistory()
const router = createRouter({ history })
history.active // true
history.active = false // will not trigger navigations in router Then create a different history instance on the sub app |
I mean, But, So, the flow was 1. If we can stop |
Sounds good then. Even though single-spa duplicating popstate events is rather a bug (if it really is duplicating them) |
Can we check whether the origin (I mean add some private property to the first param of pushState) of popState Event is from vue-router itself? Finally the private property will use to judge vue-router should response in popState listener callbacks , and then the property will be ignored or deleted . |
I don't think that's a good idea because it would just be a hack to specifically support single-spa which seems to already be doing something hacky Isn't pausing history listeners enough? |
@posva But pausing history listeners just can use once as
By the way, i use
repalce |
@beiifeng sorry, I don't understand what you are saying. |
|
Great, thanks for confirming, I need to be sure before adding it 😆 |
The final API should be |
I wanted to chime in with regards to this
The additional PopStateEvent is not a bug but an intentional design decision made by the framework to best interop with multiple routers that may be on the page. We added |
Thanks for confirming! |
qiankun主系统设置 |
该api只是表明 vue-router可以让开发者自己控制路由监听行为,不为任何微前端方案提供解决方法,需开发者根据自身情况进行设置。感谢建议。 |
What problem does this feature solve?
Some time, we watn remove history listener manaul.
For example, in qiankun micro-front. Main-app and sub-app both vue, and beforeRoute guard with main-app. I passed the
history
androuter
of the main-app to the sub-app. The sub-app used thehistory
of the main-app, and created therouter
itself, which caused the route guard in the main-app to fire twiceExample:
https://github.com/beiifeng/vue-router-next-report
Followe readme , from
首页
toHome
, then to首页
,we findBasicLayout:afterEach /Home
once in console. But findBasicLayout:afterEach
twice after we switch toPppDemo1
.Sys2Demo1
andSys2Demo2
is used api I want, only print once.It's my commit: https://github.com/beiifeng/vue-router-next/commit/b4cbbd0b80e3713aca45cb8cfa294b037aaa679c
What does the proposed API look like?
The text was updated successfully, but these errors were encountered: