state.getState() 在更新到 redux 4 时不是函数
state.getState() is not a function while updating to redux 4
目前我正在从 angular 5 迁移到 6。更新到 redux 4 时出现错误,因为 store.getState() 不是函数
export interface IAppState {
source1: IEmployee[],
source2: IEmployee[],
}
export type FSAction = FluxStandardAction<any, MetaData | null | number>;
这是史诗中间件的代码。
我在这里遇到问题,因为 store.getState() 在更新到 redux 4
时不是函数
employeeValues_Epic: Epic<FSAction, IAppState> = (action$, store) => action$
.ofType(APP_Actions.ActionTypes.APP_EMPLOYEE_VALUES).pipe(
switchMap(data => {
let state1: IEmployee[] = [];
try {
console.log("in All domain iteration");
state1 = store.getState().source1.state;
} catch (error) {
console.error(error);
}
return observableFrom(state1);
}));`
目前我正在从 angular 5 迁移到 6。更新到 redux 4 时出现错误,因为 store.getState() 不是函数
在更新到 redux 4 和 rxjs 6 后,语法已更改如下,getState() 函数已更改为值 属性。
`employeeValues_Epic: Epic<FSAction, FSAction, IAppState, any> = (action$, store) => action$
.ofType(APP_Actions.ActionTypes.APP_EMPLOYEE_VALUES).pipe(
switchMap(data => {
let state1: IEmployee[] = [];
try {
console.log("in All domain iteration");
state1 = store.value.source1.state;
} catch (error) {
console.error(error);
}
return observableFrom(state1);
}));`
阅读迁移文档https://redux-observable.js.org/MIGRATION.html#accessing-state
假定 redux-observable v1 和 rxjs v6。
- 它已更新为
store$.value
,而不是 store$.getState()
。
- 将
Observablefrom
替换为 from
。 (rxjs 5 到 6)
ofType
应该在管道中。
const employeeValues_Epic: Epic<FSAction, IAppState> = (action$, store$) => action$
.pipe(
ofType(APP_Actions.ActionTypes.APP_EMPLOYEE_VALUES),
switchMap(data => {
let state1: IEmployee[] = [];
try {
console.log("in All domain iteration");
state1 = store$.value.source1.state;
} catch (error) {
console.error(error);
}
return from(state1);
}));
目前我正在从 angular 5 迁移到 6。更新到 redux 4 时出现错误,因为 store.getState() 不是函数
export interface IAppState {
source1: IEmployee[],
source2: IEmployee[],
}
export type FSAction = FluxStandardAction<any, MetaData | null | number>;
这是史诗中间件的代码。 我在这里遇到问题,因为 store.getState() 在更新到 redux 4
时不是函数employeeValues_Epic: Epic<FSAction, IAppState> = (action$, store) => action$
.ofType(APP_Actions.ActionTypes.APP_EMPLOYEE_VALUES).pipe(
switchMap(data => {
let state1: IEmployee[] = [];
try {
console.log("in All domain iteration");
state1 = store.getState().source1.state;
} catch (error) {
console.error(error);
}
return observableFrom(state1);
}));`
目前我正在从 angular 5 迁移到 6。更新到 redux 4 时出现错误,因为 store.getState() 不是函数
在更新到 redux 4 和 rxjs 6 后,语法已更改如下,getState() 函数已更改为值 属性。
`employeeValues_Epic: Epic<FSAction, FSAction, IAppState, any> = (action$, store) => action$
.ofType(APP_Actions.ActionTypes.APP_EMPLOYEE_VALUES).pipe(
switchMap(data => {
let state1: IEmployee[] = [];
try {
console.log("in All domain iteration");
state1 = store.value.source1.state;
} catch (error) {
console.error(error);
}
return observableFrom(state1);
}));`
阅读迁移文档https://redux-observable.js.org/MIGRATION.html#accessing-state
假定 redux-observable v1 和 rxjs v6。
- 它已更新为
store$.value
,而不是store$.getState()
。 - 将
Observablefrom
替换为from
。 (rxjs 5 到 6) ofType
应该在管道中。
const employeeValues_Epic: Epic<FSAction, IAppState> = (action$, store$) => action$
.pipe(
ofType(APP_Actions.ActionTypes.APP_EMPLOYEE_VALUES),
switchMap(data => {
let state1: IEmployee[] = [];
try {
console.log("in All domain iteration");
state1 = store$.value.source1.state;
} catch (error) {
console.error(error);
}
return from(state1);
}));