Use one per thing that can be superseded — a click lookup, a search box, a refetch on map move.
Aborting stops the network work; checking again once the answer is in also catches a cancel
that arrives after the response but before the caller paints it.
const lookup = createLatestRequest();
map.mapLibreMap.on('click', async (event) => {
const result = await lookup.run((signal) => reverseGeocode({ position: event.lngLat.toArray(), signal }));
if (!result.current) return;
showAddress(result.value);
});
clearButton.addEventListener('click', lookup.cancel);
Creates a slot that keeps only the latest request: starting one aborts its predecessor, and an answer that arrives after a newer request or a
cancelis dropped rather than returned.