我知道整个网络上都有一些关于效果错误处理的示例,但就我而言,我不是在调用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 } );
} )
答案 0 :(得分:0)
我最终用地图替换了switchMap。
SELECT * FROM names where 'john smith' like wildcards