apple2js/js
Ian Flanigan 3048ec52e1
Interruptable spawn (#132)
* Add `spawn` as a way of calling promise-returning blocks

This change adds `spawn` which takes a no-argument, promise-returning
function, calls it, and returns `void`.  This makes it easy to call
async blocks from `useEffect` and other places that don't take async
functions, but also makes such calls explicit.

* Adds interruptability to `spawn`

Now, the task function passed to `spawn` can take an `Interrupted`
argument, which is merely a method that returns `true` if the task
should stop doing work. Likewise, `spawn` returns an `Interrupt`
function that causes the `Interrupted` function to return `true`.

* Change to using `AbortController` and `AbortSignal`

Before, `spawn` used functions to interrupt and determine interruption
state.  Now, based on feedback from @whscullin, it uses
`AbortController` and `AbortSignal`.

Tests now show how the controller can be used to abort long-running
tasks and API calls in the `spawn`.  The also show how signals can be
chained using `addEventListener`.

* Fix `Apple2.tsx`

Forgot to change it to use `AbortController` and `AbortSignal`.

Co-authored-by: Will Scullin <scullin@scullin.com>
2022-06-12 09:06:58 -07:00
..
applesoft Enforce strict equality (#115) 2022-05-18 08:19:45 -07:00
cards Preact mass storage (#125) 2022-06-05 10:57:04 -07:00
components Interruptable spawn (#132) 2022-06-12 09:06:58 -07:00
formats Fix 2mg header parsing and add tests (#127) 2022-06-06 18:10:06 -07:00
intbasic Enforce strict equality (#115) 2022-05-18 08:19:45 -07:00
roms Add the recommended eslint plugins for TypeScript (#121) 2022-05-31 08:38:40 -07:00
ui Preact mass storage (#125) 2022-06-05 10:57:04 -07:00
apple2.ts Add the recommended eslint plugins for TypeScript (#121) 2022-05-31 08:38:40 -07:00
apple2io.ts Fix preact apple keys 2022-06-10 19:53:40 -07:00
base64.ts Add the recommended eslint plugins for TypeScript (#121) 2022-05-31 08:38:40 -07:00
canvas.ts Enforce strict equality (#115) 2022-05-18 08:19:45 -07:00
cpu6502.ts Add the recommended eslint plugins for TypeScript (#121) 2022-05-31 08:38:40 -07:00
debugger.ts Add the recommended eslint plugins for TypeScript (#121) 2022-05-31 08:38:40 -07:00
entry.tsx Add the recommended eslint plugins for TypeScript (#121) 2022-05-31 08:38:40 -07:00
entry2.ts TypeScript remnants (#94) 2021-12-22 10:37:21 -08:00
entry2e.ts TypeScript remnants (#94) 2021-12-22 10:37:21 -08:00
gl.ts Add the recommended eslint plugins for TypeScript (#121) 2022-05-31 08:38:40 -07:00
main2.ts Preact mass storage (#125) 2022-06-05 10:57:04 -07:00
main2e.ts Preact mass storage (#125) 2022-06-05 10:57:04 -07:00
mmu.ts Add the recommended eslint plugins for TypeScript (#121) 2022-05-31 08:38:40 -07:00
options.ts Apply semi rule to interfaces (#109) 2022-05-10 08:04:20 -07:00
prefs.ts Preact UI (#106) 2022-05-10 06:52:06 -07:00
ram.ts Clean up copyright notices (#93) 2021-12-21 12:35:26 -08:00
symbols.ts More typescript conversion (#46) 2020-11-24 08:48:14 -08:00
types.ts Add the recommended eslint plugins for TypeScript (#121) 2022-05-31 08:38:40 -07:00
util.ts Fix 2mg header parsing and add tests (#127) 2022-06-06 18:10:06 -07:00
videomodes.ts Apply semi rule to interfaces (#109) 2022-05-10 08:04:20 -07:00