I want to change color (for example) of my view-component and I would like to select this component from DOM
You should not do that, the whole point of V = f(M) is that you (almost) never manipulate the DOM, the color should be part of the model and when you generate the stateRepresentation based on the new application state.
Hi. In the rocket launcher example, ¿What is the purpose of this line?
present = present || model.present ;
When i would want to pass a custom present function? in which cases?
Another question: It's a bad idea to deal with a model directly from an action instead of passing a associative-array like data to model.present() ?
For example:
function actionsLaunch()
{
model.start() //Set model->started member to true
model.present()
}
Instead of:
actions.launch = function(data, present) {
present = present || model.present ;
data.launched = true ;
present(data) ;
}
I'm trying to port it to PHP, and see how it look in an Object-Oriented like style.
Thanks you
Hi I've just started reading on SAM architecture. I like what React has been doing, but everything is actually based on a hunch to be honest, so I'll follow Kyle Simpsons advice and diversify my sources :). It's a long road, but everything begins with a first step.
I have a question;
what are your thinkings on redux-logic?
https://github.com/jeffbski/redux-logic
Best regards.
{
signal: [
...ensureSamState,
guardSamStep,
{
true: [warnBlockedAction],
false: [
set(state`sam.stepInProgress`, true),
getProposal(action),
propose,
getControlState,
ensureControlState,
{
false: [throwError("Invalid control state.")],
true: [
set(state`sam.controlState`, props`controlState`),
getNextAction,
when(props`nextAction`),
{
true: [set(state`sam.napInProgress`, true), runNextAction],
false: [
set(state`sam.napInProgress`, false),
set(state`sam.stepInProgress`, false),
],
},
],
},
],
},
],
catch: new Map([[Error, [logError]]]),
}
view.ready = function(model) {
return {
tag: 'div',
children: [
view.counter('Counter: '+model.counter),
{
tag: 'form',
events: {
onsubmit: () => actions.start({})
},
children: [
{
tag: 'div',
className: 'form-group',
children: [
{
tag: 'input',
attrs: {
type: 'submit',
value: 'Start'
}
}
]
}
]
}
]
}
}
btw i'm convinced this is THE way to manage the complexity of multiple actors attempting to modify the model - action - present - accept - model update - view update - very clean with a mathematical proof of correctness to boot - sweet.
I know that Feynman said "The first principle is that you must not fool yourself – and you are the easiest person to fool.", but after actively building large scales projects with the SAM pattern, I also believe the same thing. There is no increase in complexity of the lifespan of a project. You can always reason in simple and local terms, regardless of the size of the application. I wish I could articulate that better, and people would give it a try, and understand that the structure of their code is important and Dr. Lamport may have well found a universal structure.