diff --git a/modules/store-devtools/src/config.ts b/modules/store-devtools/src/config.ts index f5e871c5c1..724e6b07a6 100644 --- a/modules/store-devtools/src/config.ts +++ b/modules/store-devtools/src/config.ts @@ -5,12 +5,10 @@ import { InjectionToken, Type } from '@angular/core'; export interface StoreDevtoolsConfig { maxAge: number | false; monitor: ActionReducer; - shouldInstrument: Type | InjectionToken; } export const STORE_DEVTOOLS_CONFIG = new InjectionToken('@ngrx/devtools Options'); export const INITIAL_OPTIONS = new InjectionToken('@ngrx/devtools Initial Config'); -export const SHOULD_INSTRUMENT = new InjectionToken('@ngrx/devtools Should Instrument'); export type StoreDevtoolsOptions = Partial diff --git a/modules/store-devtools/src/index.ts b/modules/store-devtools/src/index.ts index a177715282..d391337366 100644 --- a/modules/store-devtools/src/index.ts +++ b/modules/store-devtools/src/index.ts @@ -1,4 +1,4 @@ export { StoreDevtoolsModule } from './instrument'; export { LiftedState } from './reducer'; export { StoreDevtools } from './devtools'; -export { StoreDevtoolsConfig, StoreDevtoolsOptions, SHOULD_INSTRUMENT } from './config'; +export { StoreDevtoolsConfig, StoreDevtoolsOptions } from './config'; diff --git a/modules/store-devtools/src/instrument.ts b/modules/store-devtools/src/instrument.ts index 5dee6693e6..3a3bbf60a9 100644 --- a/modules/store-devtools/src/instrument.ts +++ b/modules/store-devtools/src/instrument.ts @@ -14,7 +14,7 @@ import { INITIAL_REDUCERS, REDUCER_FACTORY } from '@ngrx/store'; import { StoreDevtools, DevtoolsDispatcher } from './devtools'; -import { StoreDevtoolsConfig, StoreDevtoolsOptions, STORE_DEVTOOLS_CONFIG, INITIAL_OPTIONS, SHOULD_INSTRUMENT } from './config'; +import { StoreDevtoolsConfig, StoreDevtoolsOptions, STORE_DEVTOOLS_CONFIG, INITIAL_OPTIONS } from './config'; import { DevtoolsExtension, REDUX_DEVTOOLS_EXTENSION, ReduxDevtoolsExtension } from './extension'; @@ -40,12 +40,8 @@ export function createReduxDevtoolsExtension() { } } -export function createStateObservable(shouldInstrument: boolean, injector: Injector) { - return shouldInstrument ? injector.get(StoreDevtools).state : injector.get(State); -} - -export function createReducerManagerDispatcher(shouldInstrument: boolean, injector: Injector) { - return shouldInstrument ? injector.get(DevtoolsDispatcher) : injector.get(ActionsSubject); +export function createStateObservable(devtools: StoreDevtools) { + return devtools.state; } export function noMonitor(): null { @@ -55,8 +51,7 @@ export function noMonitor(): null { export function createConfig(_options: StoreDevtoolsOptions): StoreDevtoolsConfig { const DEFAULT_OPTIONS: StoreDevtoolsConfig = { maxAge: false, - monitor: noMonitor, - shouldInstrument: IS_EXTENSION_OR_MONITOR_PRESENT, + monitor: noMonitor }; let options = typeof _options === 'function' ? _options() : _options; @@ -69,10 +64,6 @@ export function createConfig(_options: StoreDevtoolsOptions): StoreDevtoolsConfi return config; } -export function createShouldInstrument(injector: Injector, config: StoreDevtoolsConfig) { - return injector.get(config.shouldInstrument); -} - @NgModule({ imports: [ StoreModule @@ -101,11 +92,6 @@ export class StoreDevtoolsModule { provide: REDUX_DEVTOOLS_EXTENSION, useFactory: createReduxDevtoolsExtension }, - { - provide: SHOULD_INSTRUMENT, - deps: [ Injector, STORE_DEVTOOLS_CONFIG ], - useFactory: createShouldInstrument - }, { provide: STORE_DEVTOOLS_CONFIG, deps: [ INITIAL_OPTIONS ], @@ -113,13 +99,12 @@ export class StoreDevtoolsModule { }, { provide: StateObservable, - deps: [ SHOULD_INSTRUMENT, Injector ], + deps: [ StoreDevtools ], useFactory: createStateObservable }, { provide: ReducerManagerDispatcher, - deps: [ SHOULD_INSTRUMENT, Injector ], - useFactory: createReducerManagerDispatcher + useExisting: DevtoolsDispatcher }, ] }; diff --git a/modules/store/src/index.ts b/modules/store/src/index.ts index bcbfff0e9d..1e938e93ab 100644 --- a/modules/store/src/index.ts +++ b/modules/store/src/index.ts @@ -5,7 +5,7 @@ export { combineReducers, compose } from './utils'; export { ActionsSubject, INIT } from './actions_subject'; export { ReducerManager, ReducerObservable, ReducerManagerDispatcher, UPDATE } from './reducer_manager'; export { ScannedActionsSubject } from './scanned_actions_subject'; -export { createSelector, createFeatureSelector } from './selector'; +export { createSelector, createFeatureSelector, MemoizedSelector } from './selector'; export { State, StateObservable, reduceState } from './state'; export { INITIAL_STATE, REDUCER_FACTORY, INITIAL_REDUCERS, STORE_FEATURES } from './tokens'; export { StoreRootModule, StoreFeatureModule } from './store_module';