-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move metadata into internals
This commit includes several updates: 1) Moves metadata interfaces and functions to the `@ngxs/store/internals` subpackage. 2) Transfers interfaces and objects from `plugin_api.ts` to the `@ngxs/store/plugins` subpackage. 3) Adds the `@deprecated` annotation to functions and types that were exported from `public_to_deprecate.ts`.
- Loading branch information
Showing
69 changed files
with
622 additions
and
670 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
export { NgxsBootstrapper } from './ngxs-bootstrapper'; | ||
export { memoize } from './memoize'; | ||
export { INITIAL_STATE_TOKEN, InitialState } from './initial-state'; | ||
export { | ||
PlainObjectOf, | ||
PlainObject, | ||
ɵStateClass, | ||
ɵMETA_KEY, | ||
ɵMETA_OPTIONS_KEY, | ||
ɵSELECTOR_META_KEY | ||
} from './symbols'; | ||
export * from './symbols'; | ||
export * from './metadata'; | ||
export { ɵmemoize } from './memoize'; | ||
export { StateToken } from './state-token'; | ||
export { ɵINITIAL_STATE_TOKEN, ɵInitialState } from './initial-state'; | ||
export { ɵNgxsAppBootstrappedState } from './ngxs-app-bootstrapped-state'; | ||
export { ɵNGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY } from './internal-tokens'; | ||
export { ɵOrderedSubject, ɵOrderedBehaviorSubject } from './custom-rxjs-subjects'; | ||
export { ɵStateStream } from './state-stream'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
import { InjectionToken } from '@angular/core'; | ||
|
||
import { PlainObject } from './symbols'; | ||
import { ɵPlainObject } from './symbols'; | ||
|
||
declare const ngDevMode: boolean; | ||
|
||
const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode; | ||
|
||
export class InitialState { | ||
private static _value: PlainObject = {}; | ||
export class ɵInitialState { | ||
private static _value: ɵPlainObject = {}; | ||
|
||
static set(state: PlainObject) { | ||
static set(state: ɵPlainObject) { | ||
this._value = state; | ||
} | ||
|
||
static pop(): PlainObject { | ||
static pop(): ɵPlainObject { | ||
const state = this._value; | ||
this._value = {}; | ||
return state; | ||
} | ||
} | ||
|
||
export const INITIAL_STATE_TOKEN = new InjectionToken<PlainObject>( | ||
export const ɵINITIAL_STATE_TOKEN = new InjectionToken<ɵPlainObject>( | ||
NG_DEV_MODE ? 'INITIAL_STATE_TOKEN' : '', | ||
{ | ||
providedIn: 'root', | ||
factory: () => InitialState.pop() | ||
factory: () => ɵInitialState.pop() | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { | ||
ɵMETA_KEY, | ||
ɵSELECTOR_META_KEY, | ||
ɵMetaDataModel, | ||
ɵStateClassInternal, | ||
ɵSelectorMetaDataModel, | ||
ɵRuntimeSelectorContext | ||
} from './symbols'; | ||
|
||
/** | ||
* Ensures metadata is attached to the class and returns it. | ||
* | ||
* @ignore | ||
*/ | ||
export function ɵensureStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel { | ||
if (!target.hasOwnProperty(ɵMETA_KEY)) { | ||
const defaultMetadata: ɵMetaDataModel = { | ||
name: null, | ||
actions: {}, | ||
defaults: {}, | ||
path: null, | ||
makeRootSelector(context: ɵRuntimeSelectorContext) { | ||
return context.getStateGetter(defaultMetadata.name); | ||
}, | ||
children: [] | ||
}; | ||
|
||
Object.defineProperty(target, ɵMETA_KEY, { value: defaultMetadata }); | ||
} | ||
return ɵgetStoreMetadata(target); | ||
} | ||
|
||
/** | ||
* Get the metadata attached to the state class if it exists. | ||
* | ||
* @ignore | ||
*/ | ||
export function ɵgetStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel { | ||
return target[ɵMETA_KEY]!; | ||
} | ||
|
||
/** | ||
* Ensures metadata is attached to the selector and returns it. | ||
* | ||
* @ignore | ||
*/ | ||
export function ɵensureSelectorMetadata(target: Function): ɵSelectorMetaDataModel { | ||
if (!target.hasOwnProperty(ɵSELECTOR_META_KEY)) { | ||
const defaultMetadata: ɵSelectorMetaDataModel = { | ||
makeRootSelector: null, | ||
originalFn: null, | ||
containerClass: null, | ||
selectorName: null, | ||
getSelectorOptions: () => ({}) | ||
}; | ||
|
||
Object.defineProperty(target, ɵSELECTOR_META_KEY, { value: defaultMetadata }); | ||
} | ||
|
||
return ɵgetSelectorMetadata(target); | ||
} | ||
|
||
/** | ||
* Get the metadata attached to the selector if it exists. | ||
* | ||
* @ignore | ||
*/ | ||
export function ɵgetSelectorMetadata(target: any): ɵSelectorMetaDataModel { | ||
return target[ɵSELECTOR_META_KEY]; | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/store/internals/src/ngxs-app-bootstrapped-state.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { ReplaySubject } from 'rxjs'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class ɵNgxsAppBootstrappedState extends ReplaySubject<boolean> { | ||
constructor() { | ||
super(1); | ||
} | ||
|
||
bootstrap(): void { | ||
this.next(true); | ||
this.complete(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.