mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
removed duplicate functions
This commit is contained in:
@@ -1,28 +1,7 @@
|
|||||||
// @TODO: Merge with keySelector function present in 'src/app/core/shared/selectors.ts'
|
import { MemoizedSelector } from '@ngrx/store';
|
||||||
import { createSelector, MemoizedSelector, Selector } from '@ngrx/store';
|
|
||||||
import { hasValue } from '../../shared/empty.util';
|
|
||||||
import { coreSelector, CoreState } from '../core.reducers';
|
import { coreSelector, CoreState } from '../core.reducers';
|
||||||
import { JsonPatchOperationsEntry, JsonPatchOperationsResourceEntry } from './json-patch-operations.reducer';
|
import { JsonPatchOperationsEntry, JsonPatchOperationsResourceEntry } from './json-patch-operations.reducer';
|
||||||
|
import { keySelector, subStateSelector } from '../../submission/selectors';
|
||||||
export function keySelector<T, V>(parentSelector: Selector<any, any>, subState: string, key: string): MemoizedSelector<T, V> {
|
|
||||||
return createSelector(parentSelector, (state: T) => {
|
|
||||||
if (hasValue(state[subState])) {
|
|
||||||
return state[subState][key];
|
|
||||||
} else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function subStateSelector<T, V>(parentSelector: Selector<any, any>, subState: string): MemoizedSelector<T, V> {
|
|
||||||
return createSelector(parentSelector, (state: T) => {
|
|
||||||
if (hasValue(state[subState])) {
|
|
||||||
return state[subState];
|
|
||||||
} else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return MemoizedSelector to select all jsonPatchOperations for a specified resource type, stored in the state
|
* Return MemoizedSelector to select all jsonPatchOperations for a specified resource type, stored in the state
|
||||||
|
Reference in New Issue
Block a user