@vaadin/hilla-react-signals
Advanced tools
Comparing version
@@ -5,7 +5,18 @@ import type { ConnectClient, Subscription } from '@vaadin/hilla-frontend'; | ||
/** | ||
* A return type for signal operations. | ||
* A return type for signal operations that exposes a `result` property of type | ||
* `Promise`, that resolves when the operation is completed. It allows defining | ||
* callbacks to be run after the operation is completed, or error handling when | ||
* the operation fails. | ||
* | ||
* @example | ||
* ```ts | ||
* const sharedName = NameService.sharedName({ defaultValue: '' }); | ||
* sharedName.replace('John').result | ||
* .then(() => console.log('Name updated successfully')) | ||
* .catch((error) => console.error('Failed to update the name:', error)); | ||
* ``` | ||
*/ | ||
export type Operation = { | ||
export interface Operation { | ||
result: Promise<void>; | ||
}; | ||
} | ||
/** | ||
@@ -12,0 +23,0 @@ * An abstraction of a signal that tracks the number of subscribers, and calls |
@@ -119,3 +119,3 @@ import { nanoid } from "nanoid"; | ||
#operationPromises = /* @__PURE__ */ new Map(); | ||
// creates the obejct to be returned by operations to allow defining callbacks | ||
// creates the object to be returned by operations to allow defining callbacks | ||
[$createOperation]({ id, promise }) { | ||
@@ -122,0 +122,0 @@ const thens = this.#operationPromises; |
@@ -8,2 +8,3 @@ import './polyfills.js'; | ||
export { FullStackSignal } from './FullStackSignal.js'; | ||
export type { Operation } from './FullStackSignal.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -23,2 +23,3 @@ import { CollectionSignal } from './CollectionSignal.js'; | ||
* @param value - The value to insert. | ||
* @returns An operation object that allows to perform additional actions. | ||
*/ | ||
@@ -29,2 +30,3 @@ insertLast(value: T): Operation; | ||
* @param item - The item to remove. | ||
* @returns An operation object that allows to perform additional actions. | ||
*/ | ||
@@ -31,0 +33,0 @@ remove(item: ValueSignal<T>): Operation; |
@@ -122,2 +122,3 @@ import { CollectionSignal } from "./CollectionSignal.js"; | ||
* @param value - The value to insert. | ||
* @returns An operation object that allows to perform additional actions. | ||
*/ | ||
@@ -132,2 +133,3 @@ insertLast(value) { | ||
* @param item - The item to remove. | ||
* @returns An operation object that allows to perform additional actions. | ||
*/ | ||
@@ -134,0 +136,0 @@ remove(item) { |
{ | ||
"name": "@vaadin/hilla-react-signals", | ||
"version": "24.7.0-alpha6", | ||
"version": "24.7.0-alpha7", | ||
"description": "Signals for Hilla React", | ||
@@ -49,4 +49,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@preact/signals-react": "^3.0.0", | ||
"@vaadin/hilla-frontend": "24.7.0-alpha6", | ||
"@preact/signals-react": "^3.0.1", | ||
"@vaadin/hilla-frontend": "24.7.0-alpha7", | ||
"nanoid": "^5.0.9" | ||
@@ -79,4 +79,4 @@ }, | ||
"sinon-chai": "^3.7.0", | ||
"typescript": "5.7.2" | ||
"typescript": "5.7.3" | ||
} | ||
} |
@@ -23,2 +23,3 @@ import { type StateEvent } from './events.js'; | ||
* @param value - The new value. | ||
* @returns An operation object that allows to perform additional actions. | ||
*/ | ||
@@ -46,3 +47,4 @@ set(value: T): Operation; | ||
* produce the new value. | ||
* @returns An operation object that allows to perform additional actions, including cancellation. | ||
* @returns An operation object that allows to perform additional actions, | ||
* including cancellation. | ||
*/ | ||
@@ -49,0 +51,0 @@ update(callback: (value: T) => T): OperationSubscription; |
@@ -28,2 +28,3 @@ import { nanoid } from "nanoid"; | ||
* @param value - The new value. | ||
* @returns An operation object that allows to perform additional actions. | ||
*/ | ||
@@ -64,3 +65,4 @@ set(value) { | ||
* produce the new value. | ||
* @returns An operation object that allows to perform additional actions, including cancellation. | ||
* @returns An operation object that allows to perform additional actions, | ||
* including cancellation. | ||
*/ | ||
@@ -67,0 +69,0 @@ update(callback) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
87798
2.29%1041
1.96%+ Added
- Removed
Updated