Files
dspace-angular/src/app/core/index/href-index.effects.ts
William Welling 066bba28af fixed lint errors
2017-07-13 11:19:02 -05:00

35 lines
1.0 KiB
TypeScript

import { Injectable } from '@angular/core';
import { Effect, Actions } from '@ngrx/effects';
import {
ObjectCacheActionTypes, AddToObjectCacheAction,
RemoveFromObjectCacheAction
} from '../cache/object-cache.actions';
import { AddToHrefIndexAction, RemoveUUIDFromHrefIndexAction } from './href-index.actions';
import { hasValue } from '../../shared/empty.util';
@Injectable()
export class HrefIndexEffects {
@Effect() add$ = this.actions$
.ofType(ObjectCacheActionTypes.ADD)
.filter((action: AddToObjectCacheAction) => hasValue(action.payload.objectToCache.self))
.map((action: AddToObjectCacheAction) => {
return new AddToHrefIndexAction(
action.payload.objectToCache.self,
action.payload.objectToCache.uuid
);
});
@Effect() remove$ = this.actions$
.ofType(ObjectCacheActionTypes.REMOVE)
.map((action: RemoveFromObjectCacheAction) => {
return new RemoveUUIDFromHrefIndexAction(action.payload);
});
constructor(private actions$: Actions) {
}
}