Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 2x 2x 2x 2x 2x 2x 2x 3x 3x 3x 2x 1x 3x 3x | import { Injectable } from '@angular/core'; import { Actions, createEffect, ofType } from '@ngrx/effects'; import { concatMap, map, switchMap } from 'rxjs/operators'; import { mapErrorToAction, mapToPayloadProperty } from 'ish-core/utils/operators'; import { ContactService } from '../../services/contact/contact.service'; import { createContact, createContactFail, createContactSuccess, loadContact, loadContactFail, loadContactSuccess, } from './contact.actions'; @Injectable() export class ContactEffects { constructor(private actions$: Actions, private contactService: ContactService) {} /** * Load the contact subjects, which the customer can select for his request */ loadSubjects$ = createEffect(() => this.actions$.pipe( ofType(loadContact), switchMap(() => this.contactService.getContactSubjects().pipe( map(subjects => loadContactSuccess({ subjects })), mapErrorToAction(loadContactFail) ) ) ) ); /** * Send the contact request, when a customer want to get in contact with the shop */ createContact$ = createEffect(() => this.actions$.pipe( ofType(createContact), mapToPayloadProperty('contact'), concatMap(contact => this.contactService.createContactRequest(contact).pipe( map(() => createContactSuccess()), mapErrorToAction(createContactFail) ) ) ) ); } |