MCPcopy
hub / github.com/rx-angular/rx-angular / CounterComponent

Class CounterComponent

libs/state/spec/rx-state.docs.spec.ts:21–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19 `,
20})
21export class CounterComponent {
22 readonly increment = new Subject<void>();
23 readonly decrement = new Subject<void>();
24
25 private readonly state = rxState<{ count: number }>(({ connect, set }) => {
26 set({ count: 0 });
27 connect(
28 'count',
29 merge(
30 this.increment.pipe(map(() => 1)),
31 this.decrement.pipe(map(() => -1))
32 ),
33 ({ count }, slice) => count + slice
34 );
35 });
36
37 readonly count$ = this.state.select('count');
38}
39
40describe('CounterComponent', () => {
41 let fixture: ComponentFixture<CounterComponent>;

Callers

nothing calls this directly

Calls 3

rxStateFunction · 0.90
setFunction · 0.50
selectMethod · 0.45

Tested by

no test coverage detected