类:AbortController


¥Class: AbortController

稳定性: 2 - 稳定的

¥Stability: 2 - Stable

用于在选定的基于 Promise 的 API 中触发取消信号的实用工具类。该 API 基于 Web API AbortController

¥A utility class used to signal cancelation in selected Promise-based APIs. The API is based on the Web API AbortController.

const ac = new AbortController();

ac.signal.addEventListener('abort', () => console.log('Aborted!'),
                           { once: true });

ac.abort();

console.log(ac.signal.aborted);  // Prints true