Skip to content

Commit b90df34

Browse files
brandonrobertsMikeRyanDev
authored andcommitted
fix(Devtools): Removed SHOULD_INSTRUMENT token used to eagerly inject providers (#57)
We were previously using the SHOULD_INSTRUMENT token to decide whether the instrumentation should occur due to AOT. Since this is no longer needed as NgModules can be conditionally included, this code that introduces eager providers can be removed
1 parent 1f67cb3 commit b90df34

File tree

4 files changed

+8
-25
lines changed

4 files changed

+8
-25
lines changed

modules/store-devtools/src/config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import { InjectionToken, Type } from '@angular/core';
55
export interface StoreDevtoolsConfig {
66
maxAge: number | false;
77
monitor: ActionReducer<any, any>;
8-
shouldInstrument: Type<boolean> | InjectionToken<boolean>;
98
}
109

1110
export const STORE_DEVTOOLS_CONFIG = new InjectionToken<StoreDevtoolsConfig>('@ngrx/devtools Options');
1211
export const INITIAL_OPTIONS = new InjectionToken<StoreDevtoolsConfig>('@ngrx/devtools Initial Config');
13-
export const SHOULD_INSTRUMENT = new InjectionToken<boolean>('@ngrx/devtools Should Instrument');
1412

1513
export type StoreDevtoolsOptions
1614
= Partial<StoreDevtoolsConfig>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export { StoreDevtoolsModule } from './instrument';
22
export { LiftedState } from './reducer';
33
export { StoreDevtools } from './devtools';
4-
export { StoreDevtoolsConfig, StoreDevtoolsOptions, SHOULD_INSTRUMENT } from './config';
4+
export { StoreDevtoolsConfig, StoreDevtoolsOptions } from './config';

modules/store-devtools/src/instrument.ts

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
INITIAL_REDUCERS,
1515
REDUCER_FACTORY } from '@ngrx/store';
1616
import { StoreDevtools, DevtoolsDispatcher } from './devtools';
17-
import { StoreDevtoolsConfig, StoreDevtoolsOptions, STORE_DEVTOOLS_CONFIG, INITIAL_OPTIONS, SHOULD_INSTRUMENT } from './config';
17+
import { StoreDevtoolsConfig, StoreDevtoolsOptions, STORE_DEVTOOLS_CONFIG, INITIAL_OPTIONS } from './config';
1818
import { DevtoolsExtension, REDUX_DEVTOOLS_EXTENSION, ReduxDevtoolsExtension } from './extension';
1919

2020

@@ -40,12 +40,8 @@ export function createReduxDevtoolsExtension() {
4040
}
4141
}
4242

43-
export function createStateObservable(shouldInstrument: boolean, injector: Injector) {
44-
return shouldInstrument ? injector.get(StoreDevtools).state : injector.get(State);
45-
}
46-
47-
export function createReducerManagerDispatcher(shouldInstrument: boolean, injector: Injector) {
48-
return shouldInstrument ? injector.get(DevtoolsDispatcher) : injector.get(ActionsSubject);
43+
export function createStateObservable(devtools: StoreDevtools) {
44+
return devtools.state;
4945
}
5046

5147
export function noMonitor(): null {
@@ -55,8 +51,7 @@ export function noMonitor(): null {
5551
export function createConfig(_options: StoreDevtoolsOptions): StoreDevtoolsConfig {
5652
const DEFAULT_OPTIONS: StoreDevtoolsConfig = {
5753
maxAge: false,
58-
monitor: noMonitor,
59-
shouldInstrument: IS_EXTENSION_OR_MONITOR_PRESENT,
54+
monitor: noMonitor
6055
};
6156

6257
let options = typeof _options === 'function' ? _options() : _options;
@@ -69,10 +64,6 @@ export function createConfig(_options: StoreDevtoolsOptions): StoreDevtoolsConfi
6964
return config;
7065
}
7166

72-
export function createShouldInstrument(injector: Injector, config: StoreDevtoolsConfig) {
73-
return injector.get(config.shouldInstrument);
74-
}
75-
7667
@NgModule({
7768
imports: [
7869
StoreModule
@@ -101,25 +92,19 @@ export class StoreDevtoolsModule {
10192
provide: REDUX_DEVTOOLS_EXTENSION,
10293
useFactory: createReduxDevtoolsExtension
10394
},
104-
{
105-
provide: SHOULD_INSTRUMENT,
106-
deps: [ Injector, STORE_DEVTOOLS_CONFIG ],
107-
useFactory: createShouldInstrument
108-
},
10995
{
11096
provide: STORE_DEVTOOLS_CONFIG,
11197
deps: [ INITIAL_OPTIONS ],
11298
useFactory: createConfig
11399
},
114100
{
115101
provide: StateObservable,
116-
deps: [ SHOULD_INSTRUMENT, Injector ],
102+
deps: [ StoreDevtools ],
117103
useFactory: createStateObservable
118104
},
119105
{
120106
provide: ReducerManagerDispatcher,
121-
deps: [ SHOULD_INSTRUMENT, Injector ],
122-
useFactory: createReducerManagerDispatcher
107+
useExisting: DevtoolsDispatcher
123108
},
124109
]
125110
};

modules/store/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export { combineReducers, compose } from './utils';
55
export { ActionsSubject, INIT } from './actions_subject';
66
export { ReducerManager, ReducerObservable, ReducerManagerDispatcher, UPDATE } from './reducer_manager';
77
export { ScannedActionsSubject } from './scanned_actions_subject';
8-
export { createSelector, createFeatureSelector } from './selector';
8+
export { createSelector, createFeatureSelector, MemoizedSelector } from './selector';
99
export { State, StateObservable, reduceState } from './state';
1010
export { INITIAL_STATE, REDUCER_FACTORY, INITIAL_REDUCERS, STORE_FEATURES } from './tokens';
1111
export { StoreRootModule, StoreFeatureModule } from './store_module';

0 commit comments

Comments
 (0)