Application de gestion de projets. Un projet doit affecté à un utilisateur et une société qui existent

project.effects.delete.ts 1.0KB

1234567891011121314151617181920212223242526
  1. import { catchError, map } from 'rxjs/operators';
  2. import { ProjectActionTypes } from './project.action.type';
  3. import { ProjectActionUnion, DeleteProjectActionSuccess, DeleteProjectActionError } from './project.action';
  4. import { Observable, mergeMap, of } from 'rxjs';
  5. import { ProjectService } from './../../shared/services/project.service';
  6. import { Actions, createEffect, ofType } from '@ngrx/effects';
  7. import { Injectable } from "@angular/core";
  8. @Injectable()
  9. export class ProjectDeleteEffect {
  10. constructor(private projectActions: Actions, private projectService: ProjectService){}
  11. //delete project effect
  12. deleteProjectEffect : Observable<ProjectActionUnion> = createEffect(
  13. ()=> this.projectActions.pipe(
  14. ofType(ProjectActionTypes.DELETE_PROJECT),
  15. mergeMap((action: ProjectActionUnion)=>{
  16. return this.projectService.deleteProject(action.payload.projectID).pipe(
  17. map( ()=> new DeleteProjectActionSuccess(action.payload)),
  18. catchError(err => of(new DeleteProjectActionError(err)))
  19. )
  20. })
  21. )
  22. )
  23. }

Powered by TurnKey Linux.