'How to trigger route resolver manually under certain conditions, e.g. Application Window loses focus?
Before anyone marks this as a duplicate right away, this isn't a duplicate; this is about a completely different issue; I've read the replies so far. In this case, it is about a data protection mechanism.
Initial stand:
If you change to a route, an assigned resolver to this route will be automatically called. That is OK; the resolver will have been resolved, and the page will be loaded.
Imagine, the page is open in a tab, a user logged in, and some content is visible.
I want to intentionally manipulate some security-relevant information in the cookies, and I want my application to recognize this and rerun the resolvers. A watcher checks everything every half minute, but the content is still visible during this time.
The fact is that when I switch to Developer Tools, another tab, or even another program, my application window loses focus.
Question:
When I encounter a "focus/blur" I want to run the resolver programmatically:
// e.g. app.component.ts (excerpt)
@HostListener('window:focus', ['event'])
windowFocus() {
// I check if cookies OK, if not then
callResolverForThisRouteAnew () // <---- HOW ?
}
@HostListener('window:blur', ['event'])
windowFocusOut() {
// I check if cookies OK, if not then
callResolverForThisRouteAnew () // <---- HOW ?
}
I know how I should check the cookies. I need the information to call Resolvers from within the component.
FYI
That would be my solution, but maybe there are better solutions. Since this is a sub-project, I cannot influence everything here.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
