Skip to content
Snippets Groups Projects
Select Git revision
  • 36aafe213a75ec9aa71e7f1a1d3fd5330f4ec72f
  • main default protected
  • renovate/lock-file-maintenance
  • demo protected
  • person-select-custom
  • dbp-translation-component
  • icon-set-mapping
  • port-i18next-parser
  • remove-sentry
  • favorites-and-recent-files
  • revert-6c632dc6
  • lit2
  • advertisement
  • wc-part
  • automagic
  • publish
  • wip-cleanup
  • demo-file-handling
18 results

abort.js

Blame
    • Reiter, Christoph's avatar
      befe70ea
      Add AbortController related helpers · befe70ea
      Reiter, Christoph authored
      These allow linking multiple AbortControllers and ceate a timeout abort signal.
      
      For example in case you want to abort a fetch in case
      
      (1) the UI element gets removed
      (2) a newer request replacing this one gets started
      (3) a timeout happens because the fetch takes too long
      
      createLinkedAbortController() allows merging multiple signals into one
      and createTimeoutAbortSignal() allows creating a singal that auto aborts
      after some time passes.
      befe70ea
      History
      Add AbortController related helpers
      Reiter, Christoph authored
      These allow linking multiple AbortControllers and ceate a timeout abort signal.
      
      For example in case you want to abort a fetch in case
      
      (1) the UI element gets removed
      (2) a newer request replacing this one gets started
      (3) a timeout happens because the fetch takes too long
      
      createLinkedAbortController() allows merging multiple signals into one
      and createTimeoutAbortSignal() allows creating a singal that auto aborts
      after some time passes.
    abort.js 663 B
    import {assert} from 'chai';
    import {createLinkedAbortController, createTimeoutAbortSignal} from '../src/abort.js';
    
    suite('abort', () => {
        test('createLinkedAbortController', () => {
            let c1 = new AbortController();
            let c2 = new AbortController();
            const linked = createLinkedAbortController(c1.signal, c2.signal);
            assert.isFalse(linked.signal.aborted);
            c1.abort();
            assert.isTrue(linked.signal.aborted);
            c1.abort();
            linked.abort();
        });
    
        test('createTimeoutAbortSignal', () => {
            const signal = createTimeoutAbortSignal(10000000);
            assert.isFalse(signal.aborted);
        });
    });