Skip to content

Commit 5878a01

Browse files
feat(devtools): replace withEventsTracking with withTrackedReducer
Removed withEventsTracking. Use withTrackedReducer instead for automatic DevTools action naming from events. - Remove withEventsTracking feature and its test file - Export withTrackedReducer as the replacement - Remove unused onInit/DevtoolsHookContext from devtools types - Remove devtoolsEventsTracker and eventsTracking option - Update demo app to use withTrackedReducer
1 parent 4e30864 commit 5878a01

8 files changed

Lines changed: 17 additions & 331 deletions

File tree

apps/demo/src/app/events-sample/book.store.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import {
22
withDevtools,
3-
withEventsTracking,
3+
withGlitchTracking,
4+
withTrackedReducer,
45
} from '@angular-architects/ngrx-toolkit';
56
import { signalStore, withComputed, withHooks, withState } from '@ngrx/signals';
6-
import { injectDispatch, on, withReducer } from '@ngrx/signals/events';
7+
import { injectDispatch, on } from '@ngrx/signals/events';
78
import { bookEvents } from './book-events';
89
import { Book, mockBooks } from './book.model';
910

1011
export const BookStore = signalStore(
1112
{ providedIn: 'root' },
12-
withDevtools('book-store-events', withEventsTracking()),
13+
withDevtools('book-store-events', withGlitchTracking()),
1314
withState({
1415
books: [] as Book[],
1516
selectedBookId: null as string | null,
@@ -40,7 +41,7 @@ export const BookStore = signalStore(
4041
availableBooks: () => store.books().filter((book) => book.inStock).length,
4142
})),
4243

43-
withReducer(
44+
withTrackedReducer(
4445
on(bookEvents.loadBooks, () => ({
4546
books: mockBooks,
4647
})),

libs/ngrx-toolkit/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export { withDisabledNameIndices } from './lib/devtools/features/with-disabled-name-indicies';
2-
export { withEventsTracking } from './lib/devtools/features/with-events-tracking';
32
export { withGlitchTracking } from './lib/devtools/features/with-glitch-tracking';
43
export { withMapper } from './lib/devtools/features/with-mapper';
54
export {
@@ -10,6 +9,7 @@ export { renameDevtoolsName } from './lib/devtools/rename-devtools-name';
109
export { patchState, updateState } from './lib/devtools/update-state';
1110
export { withDevToolsStub } from './lib/devtools/with-dev-tools-stub';
1211
export { DevtoolsFeature, withDevtools } from './lib/devtools/with-devtools';
12+
export { withTrackedReducer } from './lib/devtools/with-tracked-reducer';
1313

1414
export {
1515
createEffects,

libs/ngrx-toolkit/src/lib/devtools/features/with-events-tracking.ts

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

libs/ngrx-toolkit/src/lib/devtools/internal/devtools-feature.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
1-
import { Observable } from 'rxjs';
21
import { Tracker } from './models';
32

43
export const DEVTOOLS_FEATURE = Symbol('DEVTOOLS_FEATURE');
54

65
export type Mapper = (state: object) => object;
76

8-
export type DevtoolsHookContext = {
9-
id: string;
10-
name: string;
11-
trackEvents: (source: Observable<{ type: string }>) => void;
12-
};
13-
147
export type DevtoolsOptions = {
158
indexNames?: boolean; // defines if names should be indexed.
169
map?: Mapper; // defines a mapper for the state.
1710
tracker?: new () => Tracker; // defines a tracker for the state
18-
eventsTracking?: boolean; // enables @ngrx/signals/events → DevTools action name tracking
19-
onInit?: (context: DevtoolsHookContext) => void; // lifecycle hook executed during devtools init
2011
};
2112

2213
export type DevtoolsInnerOptions = {
2314
indexNames: boolean;
2415
map: Mapper;
2516
tracker: Tracker;
26-
eventsTracking: boolean;
2717
};
2818

2919
/**

libs/ngrx-toolkit/src/lib/devtools/tests/with-events-tracking.spec.ts

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

libs/ngrx-toolkit/src/lib/devtools/tests/with-tracked-reducer.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
withEventHandlers,
1717
} from '@ngrx/signals/events';
1818
import { delay, tap } from 'rxjs';
19-
import { withEventsTracking } from '../features/with-events-tracking';
2019
import { withGlitchTracking } from '../features/with-glitch-tracking';
2120
import { updateState } from '../update-state';
2221
import { withDevtools } from '../with-devtools';
@@ -30,7 +29,7 @@ const testEvents = eventGroup({
3029
},
3130
});
3231

33-
describe('withEventsTracking', () => {
32+
describe('withTrackedReducer', () => {
3433
it('should send a glitched update on event', async () => {
3534
const { sendSpy, withBasicStore } = setup();
3635

@@ -139,7 +138,7 @@ describe('withEventsTracking', () => {
139138
on(testEvents.bump, (_, state) => ({ count: state.count + 1 })),
140139
),
141140
// Injecting this here, means the reducer gets notified before the tracker
142-
withDevtools('store', withEventsTracking()),
141+
withDevtools('store', withGlitchTracking()),
143142
);
144143

145144
TestBed.inject(Store);

0 commit comments

Comments
 (0)