Skip to content

Commit 25f95bc

Browse files
feat(signals): remove selectSignal and rename withSignals to withComputed (#4075)
1 parent 3dbcadc commit 25f95bc

14 files changed

+56
-338
lines changed

modules/signals/spec/select-signal.spec.ts

Lines changed: 0 additions & 208 deletions
This file was deleted.

modules/signals/spec/signal-store-feature.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { Signal, signal } from '@angular/core';
1+
import { computed, Signal, signal } from '@angular/core';
22
import {
3-
selectSignal,
43
signalStore,
54
signalStoreFeature,
65
type,
6+
withComputed,
77
withMethods,
8-
withSignals,
98
withState,
109
} from '../src';
1110
import { STATE_SIGNAL } from '../src/signal-state';
@@ -14,7 +13,7 @@ describe('signalStoreFeature', () => {
1413
function withCustomFeature1() {
1514
return signalStoreFeature(
1615
withState({ foo: 'foo' }),
17-
withSignals(({ foo }) => ({ bar: selectSignal(() => foo() + 1) })),
16+
withComputed(({ foo }) => ({ bar: computed(() => foo() + 1) })),
1817
withMethods(({ foo, bar }) => ({
1918
baz: () => foo() + bar() + 2,
2019
}))
@@ -45,8 +44,8 @@ describe('signalStoreFeature', () => {
4544
it('creates a custom feature by combining base features', () => {
4645
const Store = signalStore(
4746
withCustomFeature1(),
48-
withSignals(({ bar }) => ({
49-
s: selectSignal(() => bar() + 's'),
47+
withComputed(({ bar }) => ({
48+
s: computed(() => bar() + 's'),
5049
}))
5150
);
5251

@@ -77,7 +76,7 @@ describe('signalStoreFeature', () => {
7776
it('creates a custom feature with input', () => {
7877
const Store = signalStore(
7978
withCustomFeature1(),
80-
withSignals(() => ({ s: signal(1).asReadonly() })),
79+
withComputed(() => ({ s: signal(1).asReadonly() })),
8180
withCustomFeatureWithInput()
8281
);
8382

modules/signals/spec/signal-store.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { inject, InjectionToken, isSignal, signal } from '@angular/core';
22
import { TestBed } from '@angular/core/testing';
33
import {
44
signalStore,
5+
withComputed,
56
withHooks,
67
withMethods,
7-
withSignals,
88
withState,
99
} from '../src';
1010
import { STATE_SIGNAL } from '../src/signal-state';
@@ -84,12 +84,12 @@ describe('signalStore', () => {
8484
});
8585
});
8686

87-
describe('withSignals', () => {
87+
describe('withComputed', () => {
8888
it('provides previously defined state slices and computed signals as input argument', () => {
8989
const Store = signalStore(
9090
withState(() => ({ foo: 'foo' })),
91-
withSignals(() => ({ bar: signal('bar').asReadonly() })),
92-
withSignals(({ foo, bar }) => {
91+
withComputed(() => ({ bar: signal('bar').asReadonly() })),
92+
withComputed(({ foo, bar }) => {
9393
expect(foo()).toBe('foo');
9494
expect(bar()).toBe('bar');
9595

@@ -105,12 +105,12 @@ describe('signalStore', () => {
105105
expect(store.baz()).toBe('baz');
106106
});
107107

108-
it('executes withSignals factory in injection context', () => {
108+
it('executes withComputed factory in injection context', () => {
109109
const TOKEN = new InjectionToken('TOKEN', {
110110
providedIn: 'root',
111111
factory: () => ({ bar: signal('bar').asReadonly() }),
112112
});
113-
const Store = signalStore(withSignals(() => inject(TOKEN)));
113+
const Store = signalStore(withComputed(() => inject(TOKEN)));
114114

115115
TestBed.configureTestingModule({ providers: [Store] });
116116
const store = TestBed.inject(Store);
@@ -123,7 +123,7 @@ describe('signalStore', () => {
123123
it('provides previously defined store properties as an input argument', () => {
124124
const Store = signalStore(
125125
withState(() => ({ foo: 'foo' })),
126-
withSignals(() => ({ bar: signal('bar').asReadonly() })),
126+
withComputed(() => ({ bar: signal('bar').asReadonly() })),
127127
withMethods(() => ({ baz: () => 'baz' })),
128128
withMethods((store) => {
129129
expect(store[STATE_SIGNAL]()).toEqual({ foo: 'foo' });
@@ -199,7 +199,7 @@ describe('signalStore', () => {
199199
let message = '';
200200
const Store = signalStore(
201201
withState(() => ({ foo: 'foo' })),
202-
withSignals(() => ({ bar: signal('bar').asReadonly() })),
202+
withComputed(() => ({ bar: signal('bar').asReadonly() })),
203203
withMethods(() => ({ baz: () => 'baz' })),
204204
withHooks({
205205
onInit(store) {
@@ -221,7 +221,7 @@ describe('signalStore', () => {
221221
let message = '';
222222
const Store = signalStore(
223223
withState(() => ({ foo: 'foo' })),
224-
withSignals(() => ({ bar: signal('bar').asReadonly() })),
224+
withComputed(() => ({ bar: signal('bar').asReadonly() })),
225225
withMethods(() => ({ baz: () => 'baz' })),
226226
withHooks({
227227
onDestroy(store) {
@@ -269,7 +269,7 @@ describe('signalStore', () => {
269269
it('overrides previously defined store properties immutably', () => {
270270
const Store = signalStore(
271271
withState({ i: 1, j: 2, k: 3, l: 4 }),
272-
withSignals(({ i, j, k, l }) => {
272+
withComputed(({ i, j, k, l }) => {
273273
expect(i()).toBe(1);
274274
expect(j()).toBe(2);
275275
expect(k()).toBe(3);

0 commit comments

Comments
 (0)