Archived
26 lines
830 B
TypeScript
26 lines
830 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import { Actions, createEffect, ofType } from '@ngrx/effects';
|
|
import { first, switchMap } from 'rxjs';
|
|
import { IssueModel } from 'src/app/models/issue.model';
|
|
import { IssueService } from 'src/app/services/issues.service';
|
|
import {
|
|
receiveAllIssuesAction,
|
|
receivedAllIssuesSuccessAction,
|
|
} from '../actions/issue.actions';
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
export class IssueEffect {
|
|
preloadAutomaticOffer$ = createEffect(() => {
|
|
return this.actions$.pipe(
|
|
ofType(receiveAllIssuesAction),
|
|
switchMap((action) => this.issueService.getIssues()),
|
|
switchMap((issues: IssueModel[]) => [
|
|
receivedAllIssuesSuccessAction({ issues }),
|
|
]),
|
|
first()
|
|
);
|
|
});
|
|
|
|
constructor(private actions$: Actions, private issueService: IssueService) {}
|
|
}
|