I have a parent component, it has a side menu and content. Inside the content, a child component is rendered using router-outlet.
| menu | content |
| | |---------------------------| |
| | | child | |
| | | | |
| | | xterm | |
| | | | |
| | |---------------------------| |
At the push of a button calls method
toggleMenu(){
isCollapsed = !isCollapsed
store$.dispatch(sidenavUpdated(data))
}
the menu collapses or expands
<mat-sidenav [fxFlex]="sidenavWidth" ...
get sidenavWidth(){
If(isCollapsed){
return 40px
}
return 200px }
I should to wait for the content width to change and then in the child component, run the method to re-render the web shell (xterm.js). The child component is subscribed to changes in the store.
store$.pipe(...).subscribe (()=>{resizeTerm();})
In the debugger, the sequence of code execution is as follows
My web shell redraws before the parent template gets the new width for ".content" How can I wait for a change in the parent's html and then re-render mine web shell?
This problem can have two solutions
x
and use this time as arg of debounceTime
operator in subscribing the store
store$.pipe(debounceTime(x), ...)
ResizeObserver
api for content element and check if the element has the desired size or not
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.