Check out example codes for "typescript on window resize". It will help you in understanding the concepts better.

Code Example 1

resizeObservable$: Observable<Event>
resizeSubscription$: Subscription

ngOnInit() {
    this.resizeObservable$ = fromEvent(window, 'resize')
    this.resizeSubscription$ = this.resizeObservable$.subscribe( evt => {
      console.log('event: ', evt)
    })
}

Code Example 2

<p>Resize the browser window to fire the <code>resize</code> event.</p>
<p>Window height: <span id="height"></span></p>
<p>Window width: <span id="width"></span></p>

Code Example 3

@HostListener('window:resize', ['$event'])
onResize(event) {
  event.target.innerWidth;
}

Learn ReactJs, React Native from akashmittal.com