ing
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import { RPCService } from '@loafer/ng-rpc';
|
||||
|
||||
import { Notification } from '@overflow/commons-typescript/model/notification';
|
||||
|
||||
@@ -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)))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user