Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for cancelling a launch via an AbortController #21

Merged
merged 6 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- add support for cancelling a launch via an `AbortController`

## [0.8.1](https://github.com/arianrhodsandlot/nostalgist/compare/v0.8.0...v0.8.1) - 2024-02-24

Expand Down
6 changes: 6 additions & 0 deletions demo/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ async function gbc() {
}

async function launchNestopia() {
const abortController = new AbortController()
setTimeout(() => {
abortController.abort()
console.log(abortController.signal)
}, 500)
nostalgist = await Nostalgist.launch({
core: 'nestopia',
rom: 'pong1k.nes',
signal: abortController.signal,
})
}

Expand Down
22 changes: 22 additions & 0 deletions docs/src/content/docs/apis/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,28 @@ const nostalgist = await Nostalgist.launch({

In most cases, it is recommended to specify the size of the element through CSS or the `style` parameter first.

+ #### `signal`

**type:** `Object`

**since:** `0.9.0`

An [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) object used for cancelling a launch.

Here is an example,
```js
const abortController = new AbortController()

// Cancel the launch after 500ms
setTimeout(() => abortController.abort(), 500)

const nostalgist = await Nostalgist.launch({
core: 'fceumm',
rom: 'flappybird.nes',
signal: abortController.signal,
})
```

+ #### `runEmulatorManually`
**type:** `boolean` **default:** `false`

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
"devDependencies": {
"@arianrhodsandlot/eslint-config": "0.8.5",
"@astrojs/starlight": "0.20.1",
"@playwright/test": "1.41.2",
"@playwright/test": "1.42.0",
"@types/emscripten": "1.39.10",
"@types/ini": "4.1.0",
"@types/is-ci": "3.0.4",
"@types/wicg-file-system-access": "2023.10.4",
"astro": "4.4.4",
"astro": "4.4.5",
"browserfs": "1.4.3",
"eslint": "8.57.0",
"happy-dom": "13.5.0",
"happy-dom": "13.6.2",
"ini": "4.1.1",
"is-ci": "3.0.1",
"serve": "14.2.1",
Expand Down
92 changes: 46 additions & 46 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading