0

easy-peasy用作反应应用程序的状态管理器在我需要访问另一个模型的actionOn状态时,我如何访问?todos.itemsnotes.onAddNote

import { createStore, StoreProvider, action, actionOn } from 'easy-peasy';

const todos= {
  items: [],
  addTodo: action((state, text) => {
    state.items.push(text)
  })
};

const notes = {
  items: [],
  addNote: action((state, text) => {
      state.items.push(text)
  }),
  onAddNote: actionOn(
    (actions, storeActions) => storeActions.notes.addNote,
    (state, target) => {
        // HOW TO READ todos items
    }
  ),
};

const models = {
   todos,
   notes 
};

const store = createStore(models);

4

1 回答 1

0

制作 onAddNote athunkOn而不是actionOn

于 2021-03-10T06:44:28.070 回答