Thx for Wizar, I do my best :)
I understand the need to not trigger another action when model is still mutating. But I don't see how to compose action. Or maybe I am a bit lost in translation around your explanation. Have you got a simple concrete exemple of action composition ?
For example, does it fit the requirements?
const actionGiveMana = (manaPts, model) => {
//somelogic
...
model.present(data);
}
const actionHeal = (healPts, model) => {
//somelogic
...
model.present(data);
}
const actionCare = (manaPts, healPts, model) => {
actionGiveMana(healPts, model);
actionHeal(healPts, model);
//somelogic
...
model.present(data3, model);
}
In the case of firing actionCare
the model will be mutated twice before the final effect. But in my mind, this is still a pure function because we can reproduce the same effect with the same initial model state.
I would prefer see something like this if it makes sense to you:
var careData = actionHeal_(actionGiveMana_(healPts,model),model)
mode.present(careData)
where actionHeal() and actionGiveMana() are the pure function generating the input to the present method
const actionHeal = (healPts, model) => {
model.present(actionHeal_(healPts, model));
}