withLatestFrom 不适用于@ngrx/effects
wtihLatestFrom not working with @ngrx/effects
我试图在我的 Angular 5 项目的 ngrx 效果中访问我商店的一部分。根据 Whosebug 上的几个线程以及几篇博客文章,我正在使用 withLatestFrom 和我注入的商店。我目前正在使用 Angular 5、ngrx 4.1.1 和 rxjs 5.5.2
我的问题是,我一直收到类型错误:
error TS2339: Property 'withLatestFrom' does not exist on type 'Actions<Action>'.
这是我正在使用的代码。关于可能导致此问题的原因有什么想法吗?
import {Injectable} from '@angular/core';
import {Store} from '@ngrx/store';
import {Effect, Actions} from '@ngrx/effects';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/withLastestFrom';
import * as EndpointActions from './endpoint.actions';
import {AppState} from '../../store/app.reducers';
@Injectable()
export class EndpointEffects {
@Effect()
setEndpointData = this.actions$
.ofType(EndpointActions.SET_ENDPOINT_DATA)
.withLatestFrom(this.store$.select(state => state.endpoint.endpointAddress))
.map(([action, endpointAddress]) => {
return {
type: EndpointActions.TRY_ENDPOINT_ADDRESS,
payload: {endpointAddress: endpointAddress}
};
});
constructor(private actions$: Actions, private store$: Store<AppState>) {}
}
看起来像打字错误。我相信:
import 'rxjs/add/operator/withLastestFrom';
应该是:
import 'rxjs/add/operator/withLatestFrom';
我试图在我的 Angular 5 项目的 ngrx 效果中访问我商店的一部分。根据 Whosebug 上的几个线程以及几篇博客文章,我正在使用 withLatestFrom 和我注入的商店。我目前正在使用 Angular 5、ngrx 4.1.1 和 rxjs 5.5.2
我的问题是,我一直收到类型错误:
error TS2339: Property 'withLatestFrom' does not exist on type 'Actions<Action>'.
这是我正在使用的代码。关于可能导致此问题的原因有什么想法吗?
import {Injectable} from '@angular/core';
import {Store} from '@ngrx/store';
import {Effect, Actions} from '@ngrx/effects';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/withLastestFrom';
import * as EndpointActions from './endpoint.actions';
import {AppState} from '../../store/app.reducers';
@Injectable()
export class EndpointEffects {
@Effect()
setEndpointData = this.actions$
.ofType(EndpointActions.SET_ENDPOINT_DATA)
.withLatestFrom(this.store$.select(state => state.endpoint.endpointAddress))
.map(([action, endpointAddress]) => {
return {
type: EndpointActions.TRY_ENDPOINT_ADDRESS,
payload: {endpointAddress: endpointAddress}
};
});
constructor(private actions$: Actions, private store$: Store<AppState>) {}
}
看起来像打字错误。我相信:
import 'rxjs/add/operator/withLastestFrom';
应该是:
import 'rxjs/add/operator/withLatestFrom';