# EffectOn
# API
type EffectOn<
Model extends object = {},
StoreModel extends object = {},
Injections = any
>
ModelThe model against which the effectOn property is being defined. You need to provide this so that the state that will be provided to your effectOn is correctly typed.
StoreModelIf you expect to target state from the entire store then you will need to provide your store's model interface so that the store state is correctly typed.
InjectionsIf your store was configured with injections, and you intend to use them within your effectOn, then you should provide the type of the injections here.
# Example
import { EffectOn, effectOn } from 'easy-peasy';
interface TodosModel {
todos: string[];
onTodosChanged: EffectOn<TodosModel>;
}
const todosModel: TodosModel = {
todos: [],
onTodosChanged: effectOn(
[(state) => state.todos],
async (actions, change) => {
const [todos] = change.current;
await todosService.save(todos);
},
),
};