我有一个observable监听路由变化的:)我还有一个promise可以清除我的本地存储,完成后我立即更改路由,但我的switchMap/switchMapTo内部路由更改可观察到的值得到了旧值..为什么会发生这种情况?
我尝试了很多方法来解决这个问题 - 我发现有两种有效:)但我希望了解它们为什么有效。有人可以帮忙吗?这是关于hot/cold observables问题吗?也许有什么event loop?我真的不知道:)
this.storageService.clear().then((_) => {
// this was successful!! And it was checked - user is deleted :)
// now change the route and trigger the observable below :)
});
this.router.events.pipe(
filter((e: Event): e is NavigationEnd => e instanceof NavigationEnd)
/*
switchMap in here to get the user!
Options 1 + 2 show that the user info exists!!
Although I know for sure that …Run Code Online (Sandbox Code Playgroud)