You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once the store is defined, it gives its consumers numerous signals and methods they just need to delegate to:
116
+
117
+
```typescript
118
+
@Component(...)
119
+
exportclassFlightSearchSimpleComponent {
120
+
private store =inject(SimpleFlightBookingStore);
121
+
122
+
from =this.store.filter.from;
123
+
to =this.store.filter.to;
124
+
flights =this.store.entities;
125
+
selected =this.store.selectedEntities;
126
+
selectedIds =this.store.selectedIds;
127
+
128
+
loading =this.store.loading;
129
+
130
+
canUndo =this.store.canUndo;
131
+
canRedo =this.store.canRedo;
132
+
133
+
async search() {
134
+
this.store.load();
135
+
}
136
+
137
+
undo():void {
138
+
this.store.undo();
139
+
}
140
+
141
+
redo():void {
142
+
this.store.redo();
143
+
}
144
+
145
+
updateCriteria(from:string, to:string):void {
146
+
this.store.updateFilter({ from, to });
147
+
}
148
+
149
+
updateBasket(id:number, selected:boolean):void {
150
+
this.store.updateSelected(id, selected);
151
+
}
152
+
153
+
}
154
+
```
155
+
156
+
## DataService with Dynamic Properties
157
+
158
+
To avoid naming conflicts, the properties set up by ``withDataService`` and the connected features can be configured in a typesafe way:
159
+
160
+
```typescript
161
+
exportconst FlightBookingStore =signalStore(
162
+
{ providedIn: 'root' },
163
+
withCallState({
164
+
collection: 'flight'
165
+
}),
166
+
withEntities({
167
+
entity: type<Flight>(),
168
+
collection: 'flight'
169
+
}),
170
+
withDataService({
171
+
dataServiceType: FlightService,
172
+
filter: { from: 'Graz', to: 'Hamburg' },
173
+
collection: 'flight'
174
+
}),
175
+
withUndoRedo({
176
+
collections: ['flight'],
177
+
}),
178
+
);
179
+
```
180
+
181
+
This setup makes them use ``flight`` as part of the used property names. As these implementations respect the Type Script type system, the compiler will make sure these properties are used in a typesafe way:
0 commit comments