These are chat archives for jdubray/sam

10th
May 2016
Jean-Jacques Dubray
@jdubray
May 10 2016 14:03 UTC
That's probably why you want to use SAM on the server, but I guess I am biased.
Jean-Jacques Dubray
@jdubray
May 10 2016 21:23 UTC
So I finally got some time to (re)play with React, looks like they changed everything since 0.13.x
Here is a simple counter implementation:
<script type="text/babel">

        var model = { count: 0 } ;

        model.present = ( data ) =>  {
            data.incrementBy = data.incrementBy || 1 ;
            model.count += data.incrementBy ;
            state.render(model) ;
        } 

        var state = {} ;

        state.render = (m) => {
            ReactDOM.render(
              theme.counter(m.count),
              document.getElementById('container')
            );
        }

        var theme = { } ;

        theme.counter = (c) => <Counter count={c}/> ;


        var actions = {} ;

        actions.click = () => model.present({incrementBy:1}) ;



        var Counter = React.createClass({

            render: function () {
              return (
                <button onClick={actions.click}>
                  Click me! Number of clicks: {this.props.count}
                </button>
              );
            }
        });

      state.render(model) ;
</script>
can't be more straightforward. Not quite sure why would anyone want to use redux/sagas