Description

Often times you will make an api call, then make it again later before getting a response, to avoid displaying outdated data we must use a noice to ignore older messages.

Reach for when

You might fetch old data and need to validate its up to date.

Code

async function ignoreOldDataFetch(url) {
	let id = 0
	return async function (callback) {
		const localID = ++id
		const data = await fetch(url)
		if (localID !== id) return
		callback(data)
	}
}