UNPKG

fabric8-planner

Version:
54 lines 2.64 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 { Injectable } from '@angular/core'; import { Actions, Effect, ofType } from '@ngrx/effects'; import { Notifications } from 'ngx-base'; import { UserService } from 'ngx-login-client'; import { Observable } from 'rxjs'; import { catchError, map, switchMap } from 'rxjs/operators'; import { normalizeArray } from '../models/common.model'; import * as UserActions from './../actions/user.actions'; import { UserMapper } from './../models/user'; import { ErrorHandler } from './work-item-utils'; var UserEffects = /** @class */ (function () { function UserEffects(actions$, userService, notifications, errHandler) { var _this = this; this.actions$ = actions$; this.userService = userService; this.notifications = notifications; this.errHandler = errHandler; this.getUser$ = this.actions$ .pipe(ofType(UserActions.GET), switchMap(function (action) { return _this.userService.getUserByUserId(action.payload) .pipe(map(function (user) { var userMapper = new UserMapper(); var mappedUser = userMapper.toUIModel(user); return new UserActions.Set(normalizeArray([mappedUser])); })); }), catchError(function (err) { return _this.errHandler.handleError(err, "Problem in user details", new UserActions.GetError()); })); } UserEffects.decorators = [ { type: Injectable }, ]; /** @nocollapse */ UserEffects.ctorParameters = function () { return [ { type: Actions, }, { type: UserService, }, { type: Notifications, }, { type: ErrorHandler, }, ]; }; __decorate([ Effect(), __metadata("design:type", Observable) ], UserEffects.prototype, "getUser$", void 0); return UserEffects; }()); export { UserEffects }; //# sourceMappingURL=user.effects.js.map