easy-peasy
easy-peasy copied to clipboard
syntax error in effectOn docs
hi, in the documentation of the new effectOn api the property name in the object is missing:
import { unstable_effectOn } from 'easy-peasy';
const todosModel = {
items: [],
saving: false,
setSaving: action((state, payload) => {
state.saving = payload;
}),
unstable_effectOn(
// Provide an array of "stateResolvers" to resolve the targeted state:
[state => state.items],
// Provide a handler which will execute every time the targeted state changes:
async (actions, change) => {
const [items] = change.current;
actions.setSaving(true);
await todosService.save(items);
actions.setSaving(false);
}
)
};
should this be changed to something like:
{
onItemsChange: unstable_effectOn(...)
}
https://easy-peasy.now.sh/docs/api/effect-on.html