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

Class CounterService

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

Source from the content-addressed store, hash-verified

68
69@Injectable()
70export class CounterService {
71 readonly increment = new Subject<void>();
72 readonly decrement = new Subject<void>();
73
74 private readonly state = rxState<{ count: number }>(({ connect, set }) => {
75 set({ count: 0 });
76 connect(
77 'count',
78 merge(
79 this.increment.pipe(map(() => 1)),
80 this.decrement.pipe(map(() => -1))
81 ),
82 ({ count }, slice) => count + slice
83 );
84 });
85
86 readonly count$ = this.state.select('count');
87}
88
89const testScheduler = new TestScheduler(jestMatcher);
90

Callers

nothing calls this directly

Calls 3

rxStateFunction · 0.90
setFunction · 0.50
selectMethod · 0.45

Tested by

no test coverage detected