UNPKG

my-test123

Version:
66 lines 2.96 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { Store } from '@ngrx/store'; import { Actions, Effect } from '@ngrx/effects'; import { Injectable } from '@angular/core'; import * as AreaActions from './../actions/area.actions'; import { Observable } from 'rxjs'; import { Notifications, NotificationType } from "ngx-base"; import { AreaService as AService } from './../services/area.service'; import { AreaMapper } from './../models/area.model'; var AreaEffects = /** @class */ (function () { function AreaEffects(actions$, areaService, store, notifications) { var _this = this; this.actions$ = actions$; this.areaService = areaService; this.store = store; this.notifications = notifications; this.getAreas$ = this.actions$ .ofType(AreaActions.GET) .withLatestFrom(this.store.select('listPage').select('space')) .switchMap(function (_a) { var action = _a[0], space = _a[1]; return _this.areaService.getAreas2(space.relationships.areas.links.related) .map(function (areas) { var aMapper = new AreaMapper(); return new AreaActions.GetSuccess(areas.map(function (a) { return aMapper.toUIModel(a); })); }) .catch(function (e) { try { _this.notifications.message({ message: "Problem in fetching Areas.", type: NotificationType.DANGER }); } catch (e) { console.log('Problem in fetching Areas.'); } return Observable.of(new AreaActions.GetError()); }); }); } AreaEffects.decorators = [ { type: Injectable }, ]; /** @nocollapse */ AreaEffects.ctorParameters = function () { return [ { type: Actions, }, { type: AService, }, { type: Store, }, { type: Notifications, }, ]; }; __decorate([ Effect(), __metadata("design:type", Observable) ], AreaEffects.prototype, "getAreas$", void 0); return AreaEffects; }()); export { AreaEffects }; //# sourceMappingURL=area.effects.js.map