This commit is contained in:
crusader
2018-06-04 17:55:47 +09:00
parent ffcee6564e
commit 9990650925
34 changed files with 127 additions and 103 deletions

View File

@@ -4,15 +4,8 @@ import { Router } from '@angular/router';
import { Effect, Actions, ofType } from '@ngrx/effects';
import { Action } from '@ngrx/store';
import { Observable } from 'rxjs';
import { of } from 'rxjs/observable/of';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/exhaustMap';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/take';
import { of } from 'rxjs';
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
import { RPCClientError } from '@loafer/ng-rpc';
@@ -39,26 +32,35 @@ export class Effects {
) { }
@Effect()
readAllByMember$: Observable<Action> = this.actions$
.ofType(ActionType.ReadAllByMember)
.map((action: ReadAllByMember) => action.payload)
.switchMap(payload => this.notificationService.readAllByMember(payload.member, payload.pageParams))
.map(page => {
return new ReadAllByMemberSuccess(page);
})
.catch((error: RPCClientError) => {
return of(new ReadAllByMemberFailure(error));
});
readAllByMember$ = this.actions$.pipe(
ofType(ActionType.ReadAllByMember),
map((action: ReadAllByMember) => action.payload),
exhaustMap(payload =>
this.notificationService
.readAllByMember(payload.member, payload.pageParams)
.pipe(
map(page => {
return new ReadAllByMemberSuccess(page);
}),
catchError(error => of(new ReadAllByMemberFailure(error)))
)
)
);
@Effect()
markAllAsRead$: Observable<Action> = this.actions$
.ofType(ActionType.MarkAllAsRead)
.map((action: MarkAllAsRead) => action.payload)
.switchMap(payload => this.notificationService.markAllAsRead(payload.member, payload.pageParams))
.map(page => {
return new MarkAllAsReadSuccess(page);
})
.catch((error: RPCClientError) => {
return of(new MarkAllAsReadFailure(error));
});
markAllAsRead$ = this.actions$.pipe(
ofType(ActionType.MarkAllAsRead),
map((action: MarkAllAsRead) => action.payload),
exhaustMap(payload =>
this.notificationService
.markAllAsRead(payload.member, payload.pageParams)
.pipe(
map(page => {
return new MarkAllAsReadSuccess(page);
}),
catchError(error => of(new MarkAllAsReadFailure(error)))
)
)
);
}