Why does rsizeObzerver always run last?

Viewed 24

Here is my snippet. container is the name of a scrollable element.

let resizeObserver = new ResizeObserver((entries) => {
for (entry of entries) {
//......
resizeObserver.observe(container);

Function myFun() {//do something}
console.log (//....);

I'm wondering why every function like myFun and other functions and codes are executed before it. I know ResizeObserver is an asynchronous function and waits to end and then, we can execute the rest of codes, but when I put ResizeObserver.unobserve(container) after resizeObserver.observe(container);, function mFun and console.log (//....); is executed first again. Why? How to modify it to run those after resizeObzerver?

0 Answers
Related