小编Lau*_*t B的帖子

装饰器不支持函数调用

在构建时我遇到了一个问题--prod:

装饰器不支持函数调用,但'init'中调用'Ui'

export const initialState: AppState = {
   userAisles: null,
   userItems: null,
   userLists: null,
   userShops: null,
   ui: new Ui(),
   config: new Config(),
};
Run Code Online (Sandbox Code Playgroud)

和我的Ui班:

export class Ui {
   loading: false;
   itemsOrder = 'name';
   itemsOrderSense = 'ASC';
   listsOrder = 'date';
   listsOrderSense = 'ASC';
   listsConsultOrder = 'name';
   listsConsultOrderSense = 'ASC';
   history: string = null;
   resolved = false;

   constructor(values: Object = {}) {
      return Object.assign(this, values);
   }
}
Run Code Online (Sandbox Code Playgroud)

如果我在initialState中对Ui类进行硬编码,它会起作用然后抱怨Config类,所以问题就出现了.我没有找到任何解决方案来摆脱编译错误消息.

这是我的配置:

    "@angular/animations": "^6.0.3",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/platform-browser": …
Run Code Online (Sandbox Code Playgroud)

ngrx angular

5
推荐指数
1
解决办法
393
查看次数

避免使用 @ngrx/effects 来取消相同的操作

有没有办法避免取消前一个的影响?

我需要去做:

this.tagsStoreService.initTagsForFamilyId(this.tagFamily.id)
Run Code Online (Sandbox Code Playgroud)

我有这样的效果:

@Effect() initTagsForFamilyId$: Observable<Action> = this.actions$
    .pipe(
        ofType<InitTagsForFamilyIdAction>(TagsStateActionTypes.INIT_TAGS_FOR_FAMILY_ID_ACTION),
        switchMap(params => {
            // this.loadingService.showLoading();
            return this.tagsService.initTagsForFamilyId(params.payload)
                .pipe(
                    exhaustMap((data) => {
                        this.loadingService.hideLoading();

                        return [
                            new InitTagsForFamilyIdSuccessAction({ ...data }),
                        ];
                    }),
                    catchError(error => {
                        // this.loadingService.hideLoading();
                        return of(new TagsFailureAction({ error }));
                    }),
                );
        }),
    );
Run Code Online (Sandbox Code Playgroud)

预先感谢您的帮助;-)

ngrx ngrx-effects angular

1
推荐指数
1
解决办法
822
查看次数

标签 统计

angular ×2

ngrx ×2

ngrx-effects ×1