Skip to content

Commit e02d0d4

Browse files
refactor: use consistent naming of injection tokens across packages (#2737)
BREAKING CHANGE: The initial state Injection Token for `@ngrx/component-store` has been renamed BEFORE: Injection Token is `initialStateToken` AFTER: Injection Token is `INITIAL_STATE_TOKEN`
1 parent 0f5192d commit e02d0d4

File tree

10 files changed

+22
-23
lines changed

10 files changed

+22
-23
lines changed

modules/component-store/src/component-store.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export interface SelectConfig {
3232
debounce?: boolean;
3333
}
3434

35-
export const initialStateToken = new InjectionToken('ComponentStore InitState');
35+
export const INITIAL_STATE_TOKEN = new InjectionToken(
36+
'@ngrx/component-store Initial State'
37+
);
3638

3739
@Injectable()
3840
export class ComponentStore<T extends object> implements OnDestroy {
@@ -49,7 +51,7 @@ export class ComponentStore<T extends object> implements OnDestroy {
4951
// Needs to be after destroy$ is declared because it's used in select.
5052
readonly state$: Observable<T> = this.select((s) => s);
5153

52-
constructor(@Optional() @Inject(initialStateToken) defaultState?: T) {
54+
constructor(@Optional() @Inject(INITIAL_STATE_TOKEN) defaultState?: T) {
5355
// State can be initialized either through constructor or setState.
5456
if (defaultState) {
5557
this.initState(defaultState);

modules/data/src/effects/entity-effects-scheduler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import { SchedulerLike } from 'rxjs';
44
// See https://github.com/ReactiveX/rxjs/blob/master/doc/marble-testing.md
55
/** Token to inject a special RxJS Scheduler during marble tests. */
66
export const ENTITY_EFFECTS_SCHEDULER = new InjectionToken<SchedulerLike>(
7-
'EntityEffects Scheduler'
7+
'@ngrx/data Entity Effects Scheduler'
88
);

modules/data/src/entity-metadata/entity-metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { EntityDispatcherDefaultOptions } from '../dispatchers/entity-dispatcher
66
import { EntityFilterFn } from './entity-filters';
77

88
export const ENTITY_METADATA_TOKEN = new InjectionToken<EntityMetadataMap>(
9-
'@ngrx/data/entity-metadata'
9+
'@ngrx/data Entity Metadata'
1010
);
1111

1212
/** Metadata that describe an entity type and its collection to @ngrx/data */

modules/data/src/reducers/constants.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import { EntityCache } from './entity-cache';
44

55
export const ENTITY_CACHE_NAME = 'entityCache';
66
export const ENTITY_CACHE_NAME_TOKEN = new InjectionToken<string>(
7-
'@ngrx/data/entity-cache-name'
7+
'@ngrx/data Entity Cache Name'
88
);
99

1010
export const ENTITY_CACHE_META_REDUCERS = new InjectionToken<
1111
MetaReducer<any, any>[]
12-
>('@ngrx/data/entity-cache-meta-reducers');
12+
>('@ngrx/data Entity Cache Meta Reducers');
1313
export const ENTITY_COLLECTION_META_REDUCERS = new InjectionToken<
1414
MetaReducer<any, any>[]
15-
>('@ngrx/data/entity-collection-meta-reducers');
15+
>('@ngrx/data Entity Collection Meta Reducers');
1616

1717
export const INITIAL_ENTITY_CACHE_STATE = new InjectionToken<
1818
EntityCache | (() => EntityCache)
19-
>('@ngrx/data/initial-entity-cache-state');
19+
>('@ngrx/data Initial Entity Cache State');

modules/data/src/selectors/entity-cache-selector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88

99
export const ENTITY_CACHE_SELECTOR_TOKEN = new InjectionToken<
1010
MemoizedSelector<Object, EntityCache>
11-
>('@ngrx/data/entity-cache-selector');
11+
>('@ngrx/data Entity Cache Selector');
1212

1313
export const entityCacheSelectorProvider: FactoryProvider = {
1414
provide: ENTITY_CACHE_SELECTOR_TOKEN,

modules/data/src/utils/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface EntityPluralNames {
1414
}
1515

1616
export const PLURAL_NAMES_TOKEN = new InjectionToken<EntityPluralNames>(
17-
'@ngrx/data/plural-names'
17+
'@ngrx/data Plural Names'
1818
);
1919

2020
export abstract class Pluralizer {

modules/effects/src/tokens.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,21 @@ import { EffectsErrorHandler } from './effects_error_handler';
44
export const _ROOT_EFFECTS_GUARD = new InjectionToken<void>(
55
'@ngrx/effects Internal Root Guard'
66
);
7-
export const IMMEDIATE_EFFECTS = new InjectionToken<any[]>(
8-
'ngrx/effects: Immediate Effects'
9-
);
107
export const USER_PROVIDED_EFFECTS = new InjectionToken<Type<any>[][]>(
11-
'ngrx/effects: User Provided Effects'
8+
'@ngrx/effects User Provided Effects'
129
);
1310
export const _ROOT_EFFECTS = new InjectionToken<Type<any>[]>(
14-
'ngrx/effects: Internal Root Effects'
11+
'@ngrx/effects Internal Root Effects'
1512
);
1613
export const ROOT_EFFECTS = new InjectionToken<Type<any>[]>(
17-
'ngrx/effects: Root Effects'
14+
'@ngrx/effects Root Effects'
1815
);
1916
export const _FEATURE_EFFECTS = new InjectionToken<Type<any>[]>(
20-
'ngrx/effects: Internal Feature Effects'
17+
'@ngrx/effects Internal Feature Effects'
2118
);
2219
export const FEATURE_EFFECTS = new InjectionToken<any[][]>(
23-
'ngrx/effects: Feature Effects'
20+
'@ngrx/effects Feature Effects'
2421
);
2522
export const EFFECTS_ERROR_HANDLER = new InjectionToken<EffectsErrorHandler>(
26-
'ngrx/effects: Effects Error Handler'
23+
'@ngrx/effects Effects Error Handler'
2724
);

modules/store-devtools/src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ export class StoreDevtoolsConfig {
3939
}
4040

4141
export const STORE_DEVTOOLS_CONFIG = new InjectionToken<StoreDevtoolsConfig>(
42-
'@ngrx/devtools Options'
42+
'@ngrx/store-devtools Options'
4343
);
4444
export const INITIAL_OPTIONS = new InjectionToken<StoreDevtoolsConfig>(
45-
'@ngrx/devtools Initial Config'
45+
'@ngrx/store-devtools Initial Config'
4646
);
4747

4848
export type StoreDevtoolsOptions =

modules/store-devtools/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const ExtensionActionTypes = {
4141

4242
export const REDUX_DEVTOOLS_EXTENSION = new InjectionToken<
4343
ReduxDevtoolsExtension
44-
>('Redux Devtools Extension');
44+
>('@ngrx/store-devtools Redux Devtools Extension');
4545

4646
export interface ReduxDevtoolsExtensionConnection {
4747
subscribe(listener: (change: any) => void): void;

modules/store-devtools/src/instrument.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
import { DevtoolsDispatcher } from './devtools-dispatcher';
2020

2121
export const IS_EXTENSION_OR_MONITOR_PRESENT = new InjectionToken<boolean>(
22-
'Is Devtools Extension or Monitor Present'
22+
'@ngrx/store-devtools Is Devtools Extension or Monitor Present'
2323
);
2424

2525
export function createIsExtensionOrMonitorPresent(

0 commit comments

Comments
 (0)