Skip to content

Commit 4d87b9e

Browse files
cexbrayatpkozlowski-opensource
authored andcommitted
fix(core): rename the equality function option in toSignal (#56769) (#56922)
The option introduced in 5df3e78 has been named `equals` whereas the existing option in `signal` is named `equal`. This commit renames the new option to `equal` as well to keep the naming coherent across these APIs. PR Close #56769 PR Close #56922
1 parent 0da9eae commit 4d87b9e

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

goldens/public-api/core/rxjs-interop/index.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function toSignal<T, const U extends T>(source: Observable<T> | Subscriba
6060

6161
// @public
6262
export interface ToSignalOptions<T> {
63-
equals?: ValueEqualityFn<T>;
63+
equal?: ValueEqualityFn<T>;
6464
initialValue?: unknown;
6565
injector?: Injector;
6666
manualCleanup?: boolean;

packages/core/rxjs-interop/src/to_signal.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export interface ToSignalOptions<T> {
7777
*
7878
* Equality comparisons are executed against the initial value if one is provided.
7979
*/
80-
equals?: ValueEqualityFn<T>;
80+
equal?: ValueEqualityFn<T>;
8181
}
8282

8383
// Base case: no options -> `undefined` in the result type.
@@ -147,7 +147,7 @@ export function toSignal<T, U = undefined>(
147147
? options?.injector?.get(DestroyRef) ?? inject(DestroyRef)
148148
: null;
149149

150-
const equal = makeToSignalEquals(options?.equals);
150+
const equal = makeToSignalEqual(options?.equal);
151151

152152
// Note: T is the Observable value type, and U is the initial value type. They don't have to be
153153
// the same - the returned signal gives values of type `T`.
@@ -216,7 +216,7 @@ export function toSignal<T, U = undefined>(
216216
);
217217
}
218218

219-
function makeToSignalEquals<T>(
219+
function makeToSignalEqual<T>(
220220
userEquality: ValueEqualityFn<T> = Object.is,
221221
): ValueEqualityFn<State<T>> {
222222
return (a, b) =>

packages/core/rxjs-interop/test/to_signal_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ describe('toSignal()', () => {
251251
const counter$ = new Subject<{value: number}>();
252252
const counter = toSignal(counter$, {
253253
initialValue: {value: 0},
254-
equals: (a, b) => a.value === b.value,
254+
equal: (a, b) => a.value === b.value,
255255
});
256256

257257
let updates = 0;

0 commit comments

Comments
 (0)