【发布时间】:2019-01-17 13:27:01
【问题描述】:
我知道整个网络都有关于效果错误处理的示例,但在我的情况下,我没有调用一个 http 服务,它返回一个可观察的,就像我发现的 99% 的示例一样,所以我对构建这些示例感到茫然操作符来获得想要的效果。
我需要将我的 catchError() 移到我的 switchMap() 中
switchMap( ( [ routerState, state ] ) => {
const tenantKey = routerState.params[ 'tenantKey' ];
if ( state ) {
if ( state.tenant && state.tenant.id === tenantKey ) {
return of( { type: '[TenantContext] Tenant Context Check Valid', payload: state.tenant } );
} else {
return of( new LoadContextAction( tenantKey ) );
}
} else {
return of( new LoadContextAction( tenantKey ) );
}
} ),
catchError( ( err ) => {
return of( { type: '[TenantContext] Error', payload: err } );
} )
【问题讨论】:
标签: ngrx-effects rxjs6