( instance: T )
| 126 | } |
| 127 | |
| 128 | export function getCreateEffectMetadata<T extends Record<keyof T, Object>>( |
| 129 | instance: T |
| 130 | ): EffectMetadata<T>[] { |
| 131 | const propertyNames = Object.getOwnPropertyNames(instance) as Array<keyof T>; |
| 132 | |
| 133 | const metadata: EffectMetadata<T>[] = propertyNames |
| 134 | .filter((propertyName) => { |
| 135 | if ( |
| 136 | instance[propertyName] && |
| 137 | instance[propertyName].hasOwnProperty(CREATE_EFFECT_METADATA_KEY) |
| 138 | ) { |
| 139 | // If the property type has overridden `hasOwnProperty` we need to ensure |
| 140 | // that the metadata is valid (containing a `dispatch` property) |
| 141 | // https://github.com/ngrx/platform/issues/2975 |
| 142 | const property = instance[propertyName] as any; |
| 143 | return property[CREATE_EFFECT_METADATA_KEY].hasOwnProperty('dispatch'); |
| 144 | } |
| 145 | return false; |
| 146 | }) |
| 147 | .map((propertyName) => { |
| 148 | const metaData = (instance[propertyName] as any)[ |
| 149 | CREATE_EFFECT_METADATA_KEY |
| 150 | ]; |
| 151 | return { |
| 152 | propertyName, |
| 153 | ...metaData, |
| 154 | }; |
| 155 | }); |
| 156 | |
| 157 | return metadata; |
| 158 | } |
no test coverage detected