These are chat archives for jdubray/sam

17th
Apr 2016
Justin Litchfield
@litch
Apr 17 2016 13:37
@jdubray I see you reference EventStore in your description of a model - we've built a very robust ruby framework for building our SOA application using EventStore as the primary data store
Actually writing our EventStore client libraries has been kind of a nightmare, and actually using it is not great, but we're getting pretty good at building from it
Justin Litchfield
@litch
Apr 17 2016 16:38
Well, fun. I made my first SAM application. Such little code.
weepy
@weepy
Apr 17 2016 17:39
Can we see litch?
Basically just reimplementing the rocket-launch pattern but doing an AJAX request. I'm not really sure if I did the "AJAX request causes another action" well though
I think I like it
Justin Litchfield
@litch
Apr 17 2016 18:17
I'm wondering though abotu the wisdom of actually building something on this rather than using React. Is it "better" enough to justify building new tooling
Jean-Jacques Dubray
@jdubray
Apr 17 2016 20:45

Actually ...

microAjax('http://localhost:3000', function(res) {
        console.log(res);
        actions.receive(res, present);
      })
      present(data);

the AJAX call should be in nap(). SAM is about avoiding this kind of code (Propose -> Accept -> Learn)

Justin Litchfield
@litch
Apr 17 2016 20:45
@jdubray ok, that's where I was thinking the next logical place to put it would be
Jean-Jacques Dubray
@jdubray
Apr 17 2016 20:45
in other words, it is only because the model accepted to be "started" that the AJAX call should be allowed to proceed. The model could have refused the "started" value
You need to wrap this ajax call in a "fetch" action and invoke that action from nextAction()
Justin Litchfield
@litch
Apr 17 2016 20:50
So the "control" states of the model become started fetching fetched errored
Jean-Jacques Dubray
@jdubray
Apr 17 2016 20:50

yes, that's how I would do

Just to be clear, you don't need to use the semantics of a state machine :

if (state.fetching(model)) {
...
if-then-else work just fine, though when things get complicated, a state machine may help make the code easier to write/follow
Actions cannot be composed, there is no way around it, if you choose to do so, it is at your own risk
Justin Litchfield
@litch
Apr 17 2016 20:53
Ok, you mean the composite actions like how I had set it up previously
Jean-Jacques Dubray
@jdubray
Apr 17 2016 20:53
yes,
Justin Litchfield
@litch
Apr 17 2016 20:53
That did not feel very right
I tend to inevitably get to a state with my react/redux apps where i need to dispatch from a dispatch
And then think that it's probably best to go for a bike ride or something instead. =)
Jean-Jacques Dubray
@jdubray
Apr 17 2016 20:53
yes, that's the problem
Redux couples propose/accept and does not have nap()
you are basically doomed
Justin Litchfield
@litch
Apr 17 2016 20:55
yeah, the nap concept is very cool
That is actually something that we have struggled with in our event sourcing framewrok
the "saga"
we wind up with some kind of less-than-ideal messaging, I think, that comes from not having the nap() concept
maybe we should add that to our dispatcher in general
Jean-Jacques Dubray
@jdubray
Apr 17 2016 20:56
yes exactly,
nap is a very simple concept, given the model property values, is there anything we should do
no need for a "saga"
weepy
@weepy
Apr 17 2016 20:56
How does the coupling of propose/accept apply here ?
Jean-Jacques Dubray
@jdubray
Apr 17 2016 20:57
Sagas even break Redux's principle #1 of a single state tree
since sagas are stateful
and that don't seem to bother Dan
or anyone else who uses Redux.
Justin Litchfield
@litch
Apr 17 2016 20:57
But a stateful saga is necessary to do anything complicated well, isn't it?
Jean-Jacques Dubray
@jdubray
Apr 17 2016 20:58
not if you have nap()
nap is "stateful" but keeps the application state in the model
Justin Litchfield
@litch
Apr 17 2016 20:58
yes
Jean-Jacques Dubray
@jdubray
Apr 17 2016 20:58
there is no need for Sagas whatsoever
Justin Litchfield
@litch
Apr 17 2016 20:59
right, the state doesn't need to "leak" or the saga doesn't need to be reified, but that's still how it logically works
isn't it?
Jean-Jacques Dubray
@jdubray
Apr 17 2016 20:59
Yes exactly
absolutely!
Justin Litchfield
@litch
Apr 17 2016 21:02
Ok, and then where in that toy example would you suggest putting something so that the request would fire on page load?
Jean-Jacques Dubray
@jdubray
Apr 17 2016 21:06
the onPageLoad is another action, just like onSubmit, I don't see much difference. Am I missing something?
Justin Litchfield
@litch
Apr 17 2016 21:07
Ok, that's simple enough
Jean-Jacques Dubray
@jdubray
Apr 17 2016 21:07
got to go
Justin Litchfield
@litch
Apr 17 2016 21:08
:thumbsup: thanks. next time - node is not evil
=)
brusand
@brusand
Apr 17 2016 21:20
(Litch) in actions only all methods from ui and all API backend, un last sam component l had présent 2 kinds of datas, data.form... And data.service. with this in states i can differentiate datas from ui then un nap i can trigger API backend with ui data. It is So simple :)
Justin Litchfield
@litch
Apr 17 2016 21:23
Thanks @brusand - that reminds me of some of the ViewActionCreators vs ServerActionCreators rfom the flux implementations
brusand
@brusand
Apr 17 2016 21:26
I use sam with angular 1.5 ans after using polymères, i prefer and far beyond stay with angular 1 with sam :)
No need more
Justin Litchfield
@litch
Apr 17 2016 21:26
You are using angular mostly for the templating?
brusand
@brusand
Apr 17 2016 21:31
Yes i differ templates in the link méthode with $compile(view)($scope) ans it ll rock like a charm, (see my rocket angular sample )
Jean-Jacques Dubray
@jdubray
Apr 17 2016 23:16
similarly, I believe Stateless React components can be used to implement the view:
view.ready = function(model) {
      return (
        "<p>Start action?</p>\n\
          <form onSubmit=\"JavaScript:return actions.start({});\">\n\
            <input type=\"submit\" value=\"Start\">\n\
          </form>"
      );
    }