-
-
Save ensisf/61ad8f342dcac8957f955d38acce3652 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Глобальный счётчик запросов | |
| let lastRequest = 0 | |
| export function send (...args, callback) { | |
| // Запоминаем какой номер у этого запроса | |
| const thisRequest = ++lastRequest | |
| fetch(...args).then(responce => { | |
| // Игнорируем ответ, если номер этого запроса | |
| // не совпадает с номером последнего | |
| if (thisRequest !== lastRequest) return | |
| callback(responce) | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment