@quilted/events
Advanced tools
Comparing version 0.0.0-preview-20240731033135 to 0.0.0-preview-20240816174814
@@ -20,4 +20,4 @@ /** | ||
export declare class NestedAbortController extends AbortController { | ||
constructor(...parents: AbortSignal[]); | ||
constructor(...parents: Pick<AbortSignal, 'aborted' | 'reason' | 'addEventListener'>[]); | ||
} | ||
//# sourceMappingURL=NestedAbortController.d.ts.map |
# @quilted/events | ||
## 0.0.0-preview-20240731033135 | ||
## 0.0.0-preview-20240816174814 | ||
### Minor Changes | ||
### Patch Changes | ||
- Add `EventTargetSignal` class for converting an `EventTarget` into a Preact signal | ||
- Changed Preact thread utilities to be class-based instead of being a collection of utility functions. | ||
Previously, you used `createThreadSignal()` to serialize a Preact signal to pass over a thread, and `acceptThreadSignal()` to turn it into a "live" signal. With the new API, you will do the same steps, but with `ThreadSignal.serialize()` and `new ThreadSignal()`: | ||
```js | ||
import {signal, computed} from '@preact/signals-core'; | ||
import {ThreadWebWorker, ThreadSignal} from '@quilted/threads'; | ||
// Old API: | ||
const result = signal(32); | ||
const serializedSignal = createThreadSignal(result); | ||
await thread.imports.calculateResult(serializedSignal); | ||
// New API: | ||
const result = signal(32); | ||
const serializedSignal = ThreadSignal.serialize(result); | ||
await thread.imports.calculateResult(serializedSignal); | ||
// In the target thread: | ||
// Old API: | ||
function calculateResult(resultThreadSignal) { | ||
const result = acceptThreadSignal(resultThreadSignal); | ||
const computedSignal = computed( | ||
() => `Result from thread: ${result.value}`, | ||
); | ||
// ... | ||
} | ||
// New API: | ||
function calculateResult(resultThreadSignal) { | ||
const result = new ThreadSignal(resultThreadSignal); | ||
const computedSignal = computed( | ||
() => `Result from thread: ${result.value}`, | ||
); | ||
// ... | ||
} | ||
``` | ||
## 2.1.1 | ||
### Patch Changes | ||
- [#818](https://github.com/lemonmade/quilt/pull/818) [`8669216`](https://github.com/lemonmade/quilt/commit/8669216a28c6d8b5b62d4f297ece8f44b8f9f3ae) Thanks [@lemonmade](https://github.com/lemonmade)! - Changed Preact thread utilities to be class-based instead of being a collection of utility functions. | ||
Previously, you used `createThreadSignal()` to serialize a Preact signal to pass over a thread, and `acceptThreadSignal()` to turn it into a "live" signal. With the new API, you will do the same steps, but with `ThreadSignal.serialize()` and `new ThreadSignal()`: | ||
```js | ||
import {signal, computed} from '@preact/signals-core'; | ||
import {ThreadWebWorker, ThreadSignal} from '@quilted/threads'; | ||
// Old API: | ||
const result = signal(32); | ||
const serializedSignal = createThreadSignal(result); | ||
await thread.imports.calculateResult(serializedSignal); | ||
// New API: | ||
const result = signal(32); | ||
const serializedSignal = ThreadSignal.serialize(result); | ||
await thread.imports.calculateResult(serializedSignal); | ||
// In the target thread: | ||
// Old API: | ||
function calculateResult(resultThreadSignal) { | ||
const result = acceptThreadSignal(resultThreadSignal); | ||
const computedSignal = computed( | ||
() => `Result from thread: ${result.value}`, | ||
); | ||
// ... | ||
} | ||
// New API: | ||
function calculateResult(resultThreadSignal) { | ||
const result = new ThreadSignal(resultThreadSignal); | ||
const computedSignal = computed( | ||
() => `Result from thread: ${result.value}`, | ||
); | ||
// ... | ||
} | ||
``` | ||
## 2.1.0 | ||
@@ -10,0 +90,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "0.0.0-preview-20240731033135", | ||
"version": "0.0.0-preview-20240816174814", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "engines": { |
@@ -20,3 +20,5 @@ /** | ||
export class NestedAbortController extends AbortController { | ||
constructor(...parents: AbortSignal[]) { | ||
constructor( | ||
...parents: Pick<AbortSignal, 'aborted' | 'reason' | 'addEventListener'>[] | ||
) { | ||
super(); | ||
@@ -23,0 +25,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
162629
2227