在NgRX

问题描述

我一直在尝试解决这一部分。

export const personReducer = createReducer(
    initialState,on(LOAD_ALL_SUCCESS,(state,{ list }) => {
        // list.push(state.entities)
        const tmpArr : Person[] = Object.values(state.entities)
        
        tmpArr.forEach(t =>{
            list.push(t)
        })

        return adapter.addAll(list,{
            ...state,loaded: true,loading: false,saved201: false,updated200: false,error: undefined,formState: undefined,})
    }),)

我的目标是将以前的状态添加到当前状态,以便我的人员列表包含我将在UI中显示的先前和当前状态。 这意味着即使移至下一页,我也必须显示所有内容。

我以为我可以将state.entities从字典转换为数组,但这给我一个错误。有什么方法可以实现我的目标?

顺便说一句。在我的用户界面中,我没有使用典型的分页功能,而是向下滚动(如果滚动到达Facebook新闻提要中的底部,则会显示或拉出数据)

我正在使用ngrx v10 https://ngrx.io/

    "@ngrx/effects": "^10.0.0","@ngrx/entity": "^10.0.0","@ngrx/router-store": "^10.0.0","@ngrx/store": "^10.0.0","@ngrx/store-devtools": "^10.0.0","@rxweb/reactive-form-validators": "^2.0.0",

用于选择器

export const selectAll = createSelector(
    selectorPersonFeature,adapter.getSelectors().selectAll
)

所以我结束了这个。

this.store.pipe(select(selectAll))
      .subscribe((p: Person[]) => {
        p.forEach(i => {
          this.person$.push(i)
        })
      })

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)