我试图创建一个常量来放置所有操作,但当我实现它时,我得到了他的错误:
Argument of type 'OperatorFunction<Action, Action>' is not assignable to parameter of type 'OperatorFunction<Action, { pageSize: number; pageIndex: number; }>'. Type 'Action' is missing the following properties from type '{ pageSize: number; pageIndex: number; }': pageSize, pageIndex
个
之前(工作正常):
paginateStudents$ = createEffect(()=>this.actions$.pipe(
ofType('[Student List] Paginate students'),
mergeMap((action: {pageSize: number; pageIndex: number})=> this.studentService.getAll(action.pageSize,action.pageIndex)
.pipe(
map((students: StudentResponse) => ({type: ACTIONS.PAGINATE_STUDENTS_SUCCESS, payload:{
studentList: students.data,
pageSize: students.pageSize
}})),
catchError(()=> EMPTY)
))
));
之后(不起作用):
paginateStudents$ = createEffect(()=>this.actions$.pipe(
ofType(ACTIONS.PAGINATE_STUDENTS),
mergeMap((action: {pageSize: number; pageIndex: number})=> this.studentService.getAll(action.pageSize,action.pageIndex)
.pipe(
map((students: StudentResponse) => ({type: ACTIONS.PAGINATE_STUDENTS_SUCCESS, payload:{
studentList: students.data,
pageSize: students.pageSize
}})),
catchError(()=> EMPTY)
))
));
常量操作列表:
export const ACTIONS = {
...
PAGINATE_STUDENTS: '[Student List] Paginate students',
...
}
学生.操作:
export const paginatedStudents = createAction(
ACTIONS.PAGINATE_STUDENTS_SUCCESS,
props<{
payload: {
studentList: readonly Student[];
pageSize: number
}
}>()
);