The AbortController interface enables us to cancel a one or more DOM requests. In this lesson, we will demonstrate how to use the controller to cancel a Javascript Promise before it is resolved.

 

const controller = new AbortController();
const signal = controller.signal;

The controller only has one method:

controller.abort();

When you do this, it notifies the signal:

 
signal.addEventListener('abort', () => {
  // Logs true:
  console.log(signal.aborted);
});

 

Read More

 

相关文章:

  • 2022-12-23
  • 2022-01-21
  • 2021-06-19
  • 2021-09-22
  • 2022-12-23
  • 2021-08-19
  • 2021-11-18
  • 2022-01-06
猜你喜欢
  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
  • 2021-11-06
  • 2021-12-12
相关资源
相似解决方案