(MailNgrx) Fixed depreciated ngrx/rxjs stuff

This commit is contained in:
Sercan Yemen 2018-08-28 08:07:17 +03:00
parent 9630d0154f
commit 0b2af161f4
2 changed files with 17 additions and 17 deletions

View File

@ -51,7 +51,7 @@ export class ContactsMainSidebarComponent implements OnInit, OnDestroy
/**
* On destroy
*/
ngOnDestroy()
ngOnDestroy(): void
{
// Unsubscribe from all subscriptions
this._unsubscribeAll.next();

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Action, Store } from '@ngrx/store';
import { Action, select, Store } from '@ngrx/store';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Observable, of, forkJoin } from 'rxjs';
@ -24,12 +24,14 @@ export class MailsEffect
private store: Store<State>
)
{
this.store.select(getRouterState).subscribe(routerState => {
if ( routerState )
{
this.routerState = routerState.state;
}
});
this.store
.pipe(select(getRouterState))
.subscribe(routerState => {
if ( routerState )
{
this.routerState = routerState.state;
}
});
}
/**
@ -101,11 +103,9 @@ export class MailsEffect
.pipe(
ofType<MailsActions.UpdateMails>(MailsActions.UPDATE_MAILS),
exhaustMap((action) => {
return forkJoin(
action.payload.map(mail => this.mailService.updateMail(mail)),
() => {
return new MailsActions.UpdateMailsSuccess();
});
return forkJoin(action.payload.map(mail => this.mailService.updateMail(mail))).pipe(map(() => {
return new MailsActions.UpdateMailsSuccess();
}));
})
);
@ -118,7 +118,7 @@ export class MailsEffect
this.actions
.pipe(
ofType<MailsActions.SetCurrentMail>(MailsActions.SET_CURRENT_MAIL),
withLatestFrom(this.store.select(getMailsState)),
withLatestFrom(this.store.pipe(select(getMailsState))),
map(([action, state]) => {
return new MailsActions.SetCurrentMailSuccess(state.entities[action.payload]);
})
@ -135,7 +135,7 @@ export class MailsEffect
this.actions
.pipe(
ofType<MailsActions.CheckCurrentMail>(MailsActions.CHECK_CURRENT_MAIL),
withLatestFrom(this.store.select(getMailsState)),
withLatestFrom(this.store.pipe(select(getMailsState))),
map(([action, state]) => {
if ( !state.entities[this.routerState.params.mailId] )
@ -200,7 +200,7 @@ export class MailsEffect
.pipe(
ofType<MailsActions.SetFolderOnSelectedMails>(MailsActions.SET_FOLDER_ON_SELECTED_MAILS),
withLatestFrom(
this.store.select(getMailsState)),
this.store.pipe(select(getMailsState))),
map(([action, state]) => {
const entities = {...state.entities};
let mailsToUpdate = [];
@ -227,7 +227,7 @@ export class MailsEffect
this.actions
.pipe(
ofType<MailsActions.AddLabelOnSelectedMails>(MailsActions.ADD_LABEL_ON_SELECTED_MAILS),
withLatestFrom(this.store.select(getMailsState)),
withLatestFrom(this.store.pipe(select(getMailsState))),
map(([action, state]) => {
const entities = {...state.entities};