If you want just one event after the resize is finished, it's better to use RxJS with debounceTime :debounceTime: Discard emitted values that take less than the specified time between output.
He waits > 0.5s between 2 events emitted before running the code.In simpler terms, it waits for the resizing to be finished before executing the next code.
// RxJS v6+import { fromEvent } from 'rxjs';import { debounceTime, map } from 'rxjs/operators';...const resize$ = fromEvent(window, 'resize'); resize$ .pipe( map((i: any) => i), debounceTime(500) // He waits > 0.5s between 2 events emitted before running the next. ) .subscribe((event) => { console.log('resize is finished'); });