Angular 使用RXJS 6中的减速器内部维修

Angular 使用RXJS 6中的减速器内部维修,angular,redux,rxjs,reducers,ngrx-effects,Angular,Redux,Rxjs,Reducers,Ngrx Effects,在身份验证的作用下,我正在处理服务器错误: catchError((err, caught) => { let toasterPayload = { title: 'Error', message: err, conf: {} } return [ { type: CoreActions.SHOW_ERROR_TOASTR, payload: toasterPaylo

在身份验证的作用下,我正在处理服务器错误:

catchError((err, caught) => {
   let toasterPayload = {
       title: 'Error',
       message: err,
       conf: {}
    }

    return [
       {
           type: CoreActions.SHOW_ERROR_TOASTR,
           payload: toasterPayload
       },
       caught
    ];
目标是让可观察到的流流动,然后发送一个显示烤面包机的动作。为了重复字符串
this.toastrService.error(…,…)
,在我的应用程序的所有效果的witch catchError中,我编写了一个通用和常见的操作(SHOW_error_TOASTR):

在reducer文件的顶部,我导入了Toastr服务:

import * as toastrService from 'ngx-toastr';
但它输出以下错误:

类型“C:/Users/myPc/projects/test/node_modules/ngx toastr/ngx toastr”上不存在属性“error”


如何在reducer中正确地注入(并使用)服务?这是一个集中代码的好做法吗(不要在所有catchErrors中重复烤面包机)?

是否应该从“ngx toastr”导入{ToastrService}我已经尝试过了,但它不工作相同的错误或新的错误?导入:从'ngx toastr'导入{ToastrService};并写入:this.ToastrService.error(..)它编译正确,但在调度操作时,浏览器控制台中出现此错误:无法读取未定义的属性“ToastrService”。只写ToastrService.error(..),所以如果没有'this',我就有这个编译错误:属性'error'在类型'typeof ToastrService'上不存在,请显示构造函数
import * as toastrService from 'ngx-toastr';