These are chat archives for jdubray/sam

30th
Jun 2016
Fred Daoud
@foxdonut
Jun 30 2016 14:00
@edmulraney I think "present" and "propose" are synonyms, you are presenting something to the model, or you are proposing something to the model. Now, when you have model.present, then calling model.present(...) from the action is presenting/proposing, but on the model object, model.present is actually receiving/considering/accepting, it is one function serving both purposes. In Meiosis, they are separate functions, propose and receive.
devin ivy
@devinivy
Jun 30 2016 14:04
so you implement receive and you call propose
Jean-Jacques Dubray
@jdubray
Jun 30 2016 14:07
@foxdonut I would say be careful of slight variations on the semantics. Having this in the view is not correct:
actions.start();
you need to send an init action to bootstrap the system (onLoad,...) but in general you don't want the view to know too much (if anything) about actions.
In practice, when you render a view the system has already been initialized since a State representation has been created
Fred Daoud
@foxdonut
Jun 30 2016 14:10
@jdubray Where do you see actions.start()?
Jean-Jacques Dubray
@jdubray
Jun 30 2016 14:10
The view components have placeholders for "actions" and the state function injects "intents" to wire the components to the application actions
here:
const view = {
  // State representation of the ready state
  ready: (model, actions) => {
    const onStart = function(evt) {
      evt.preventDefault();
      actions.start();
    };
view.ready is the state representation of the "ready" control state
Fred Daoud
@foxdonut
Jun 30 2016 14:13
@jdubray that is not to initialize the system. this is to start the countdown, as a result of pressing the Start button. this is no different than your example:
// State representation of the ready state
view.ready = function(model) {
    return (
            "<p>Counter:"+model.counter+"</p>\n\
            <form onSubmit=\"JavaScript:actions.start({});return false;\">\n\
                <input type=\"submit\" value=\"Start\">\n\
            </form>"
        ) ;

}
Jean-Jacques Dubray
@jdubray
Jun 30 2016 14:14
in other words it would be better to pass: actions.abort as part of the state representation
In my original they were globals, but if you pass something, it should not be orchestrated by the State function
The State function should make the determination as to which action are allowed and wired to the view.
Jean-Jacques Dubray
@jdubray
Jun 30 2016 14:23
yes, I understand (sorry need more coffee)
Fred Daoud
@foxdonut
Jun 30 2016 14:23
no problem at all, I am always grateful for reviewing my work and getting your thoughts and feedback! :coffee:
Jean-Jacques Dubray
@jdubray
Jun 30 2016 14:23
You still would want the state representation to pick the action for the view
This should be in the State
const onAbort = function(evt) {
      evt.preventDefault();
      actions.abort();
    };
If you had a dispatcher (which I recommend for any sizeable app), then you'd be able to easily control the allowed actions and wire these actions into the view
Fred Daoud
@foxdonut
Jun 30 2016 14:27
@jdubray I agree, in fact that is what I am doing in the todomvc example, that code is not in the view.
https://github.com/foxdonut/meiosis-examples/blob/master/examples/todomvc/common/main/actions.js#L35-L39
Jean-Jacques Dubray
@jdubray
Jun 30 2016 19:18
I have restructured a bit the presentation I gave at NodePDX:
https://www.youtube.com/watch?v=4QcjAqIy0nw&feature=youtu.be
(I didn't pick the still picture, I guess YouTube got the memo, Semantics does matter)