Use one per thing that can be superseded, like a click lookup, a search box or 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 arriving after a newer request or a
cancelis dropped rather than returned.