Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Devtools): Removed SHOULD_INSTRUMENT token #57

Merged
merged 1 commit into from
Jul 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions modules/store-devtools/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import { InjectionToken, Type } from '@angular/core';
export interface StoreDevtoolsConfig {
maxAge: number | false;
monitor: ActionReducer<any, any>;
shouldInstrument: Type<boolean> | InjectionToken<boolean>;
}

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

export type StoreDevtoolsOptions
= Partial<StoreDevtoolsConfig>
Expand Down
2 changes: 1 addition & 1 deletion modules/store-devtools/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
27 changes: 6 additions & 21 deletions modules/store-devtools/src/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';


Expand All @@ -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 {
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -101,25 +92,19 @@ 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 ],
useFactory: createConfig
},
{
provide: StateObservable,
deps: [ SHOULD_INSTRUMENT, Injector ],
deps: [ StoreDevtools ],
useFactory: createStateObservable
},
{
provide: ReducerManagerDispatcher,
deps: [ SHOULD_INSTRUMENT, Injector ],
useFactory: createReducerManagerDispatcher
useExisting: DevtoolsDispatcher
},
]
};
Expand Down
2 changes: 1 addition & 1 deletion modules/store/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';