import { ActionType } from './type'; export const NGRX_STORE_META = '__ngrx__store__'; export interface StoreMetadata { initialState?: any; actions: ActionsMeta; effects: ActionsMeta; } export interface ActionMeta { action: ActionType; methodName: string; type: string; } export interface ActionsMeta { [type: string]: ActionMeta; } export function ensureStoreMetadata(target: any): StoreMetadata { // see https://github.com/angular/angular/blob/master/packages/core/src/util/decorators.ts#L60 if (!target.hasOwnProperty(NGRX_STORE_META)) { const defaultMetadata: StoreMetadata = { actions: {}, effects: {} }; Object.defineProperty(target, NGRX_STORE_META, { value: defaultMetadata }); } return target[NGRX_STORE_META]; }