Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

feat(Util): support AbortSignal in entersState #171

Merged
merged 5 commits into from
Aug 8, 2021

Conversation

amishshah
Copy link
Member

@amishshah amishshah commented Aug 8, 2021

Please describe the changes this PR makes and why it should be merged:

Resolves #169

Allows users to pass in an AbortSignal to entersState if they'd like more control than just a timeout over cancelling the operation. Still allows for passing a delay as a number, but the minimum Node.js version has been upped to v16.

// Still backwards-compatible
await entersState(vc, VoiceConnectionStatus.Ready, 1000);

// New support for AbortSignals
// entersState will abort once 'someEvent' is emitted
const ac = new AbortController();
eventEmitter.once('someEvent', () => ac.abort());
await entersState(vc, VoiceConnectionStatus.Ready, ac.signal);

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • This PR changes the library's interface (methods or parameters added)
  • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)

@codecov
Copy link

codecov bot commented Aug 8, 2021

Codecov Report

Merging #171 (a693038) into main (dd5751b) will increase coverage by 1.26%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #171      +/-   ##
==========================================
+ Coverage   71.52%   72.78%   +1.26%     
==========================================
  Files          19       20       +1     
  Lines         906      904       -2     
  Branches      215      216       +1     
==========================================
+ Hits          648      658      +10     
+ Misses        256      244      -12     
  Partials        2        2              
Impacted Files Coverage Δ
src/util/abortAfter.ts 100.00% <100.00%> (ø)
src/util/entersState.ts 100.00% <100.00%> (+100.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dd5751b...a693038. Read the comment docs.

@amishshah amishshah changed the title feat(Utils): support AbortSignal in entersState feat(Util): support AbortSignal in entersState Aug 8, 2021
@amishshah amishshah force-pushed the feat/abort-controller branch from 824c8f4 to 219fed4 Compare August 8, 2021 11:47
@amishshah amishshah marked this pull request as ready for review August 8, 2021 12:14
@amishshah amishshah force-pushed the feat/abort-controller branch from 4bcb5d6 to a693038 Compare August 8, 2021 12:59
@amishshah amishshah merged commit 636f54f into main Aug 8, 2021
@amishshah amishshah deleted the feat/abort-controller branch August 8, 2021 20:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor to use AbortController in entersState
3 participants