refactor: ngrx-store use enum ActionTypes and Action classes everywhere (#919)
This commit is contained in:
committed by
László Monda
parent
de71f6f88c
commit
7a2c8cb2e4
@@ -15,28 +15,6 @@ export function capitalizeFirstLetter(text: string): string {
|
||||
return text.charAt(0).toUpperCase() + text.slice(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function coerces a string into a string literal type.
|
||||
* Using tagged union types in TypeScript 2.0, this enables
|
||||
* powerful typechecking of our reducers.
|
||||
*
|
||||
* Since every action label passes through this function it
|
||||
* is a good place to ensure all of our action labels
|
||||
* are unique.
|
||||
*/
|
||||
|
||||
const typeCache: { [label: string]: boolean } = {};
|
||||
|
||||
export function type<T>(label: T | ''): T {
|
||||
if (typeCache[<string>label]) {
|
||||
throw new Error(`Action type "${label}" is not unique"`);
|
||||
}
|
||||
|
||||
typeCache[<string>label] = true;
|
||||
|
||||
return <T>label;
|
||||
}
|
||||
|
||||
export function runInElectron() {
|
||||
return window && (<any>window).process && (<any>window).process.type;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user