'Fetch vector tiles after zoom/pan ends in Openlayers 6

I am trying to optimize the vector tile loading from my local server. Is there any way or any tileLoadFunction to fetch the tiles only after zoom/pan ends.

I am currently using the below function to optimize

    tileLoadFunction: (tile, url) => {
      tile.setLoader(function (extent, _resolution, projection) {
        map.once("moveend", () => {
          setTimeout(() => {
            getTile(url, tile, extent, projection);
          }, 1000);
        });
      });
    },

The settimeout works fine but it fetches all the zoom/pan tiles. I want only the last zoomed/panned tile.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source