These are chat archives for jdubray/sam

29th
May 2017
Radosavljevic Slobodan
@radosavljevic
May 29 2017 02:49 UTC
@jdubray SAM + SAM diagram tells that API calls can also be made from the model? I thought the model is only concerned with data integrity? Would you care to give an example?
Victor Noël
@victornoel
May 29 2017 07:33 UTC
@radosavljevic I think the idea is that API operations related to mutation (for example create-update-delete in CRUD) could be taken care of in model, that's what @jdubray told he was doing often
(since the model is the one responsible of mutations)
Jean-Jacques Dubray
@jdubray
May 29 2017 13:07 UTC
@victornoel @radosavljevic exactly, with the SAM pattern you have an opportunity to align Actions with APIs and the Model with the Service layer (calling Microservices as integration points to the systems of record)
The back-end is always architected around three concerns:
  • Activity
  • Consistency
  • Durability
With MVC like frameworks or anemic frameworks like Redux/Elem, calling an "api" is an after-thought, just a side-effect like any other, there is no particular articulation or alignment with the back-end semantics.
Jean-Jacques Dubray
@jdubray
May 29 2017 13:15 UTC
For Angular2 for instance, the back-end is just an "HTTP call" (a category of services)
SAM not only is isomorphic by design, but its semantics are directly aligned with Back-End semantics.
Johan Alkstål
@johanalkstal
May 29 2017 13:32 UTC

I think it's natural that the Model would be the one calling the server to persist some data that has passed the Models integrity check.

It would not make sense to have an Action send a request to save data, before the proposed data has been validated.

The Model could then also reject to persist the proposal on the client, if the server for some reasons returns an error when it tried to save the data, to keep the Model consistent with the data on the server?

Jean-Jacques Dubray
@jdubray
May 29 2017 13:35 UTC
Yes, I agree, that's a much better value proposition than an immutable state and pure function with declarative side-effects, persistence is part of the "access/reject" process and only once the parts of the model that need to be persisted actually are that you can complete the loop. Of course not all properties of the model need to be persisted.
Imagine the same kind of scenario with Elm and Redux (immutable model/pure function), you trigger an action to persist these properties... then you need an ancillary state machine to deal with it and you have to make sure no other action processed in the mean time interferes wiht it. Which one is more natural?
Johan Alkstål
@johanalkstal
May 29 2017 13:51 UTC
Since a request is an asyncronous action, how would you make sure no other action is processed until the OK response is returned?
Jean-Jacques Dubray
@jdubray
May 29 2017 13:56 UTC
Good question, you would need something like SAM-SAFE if it's a complex UX, or if it's a single user app wiht no external event you can use a modal/back-drop to prevent the user from triggering more actions.
Jean-Jacques Dubray
@jdubray
May 29 2017 15:16 UTC
Not sure if people have played with Vue yet, but I am trying to do something as simple as calling a setTimeout in a method and that seems impossible. People have suggested using Vue.nextTick, but that doesn't seem to work.
Daniel Neveux
@dagatsoin
May 29 2017 15:19 UTC
never used in method, but works in an action
Jean-Jacques Dubray
@jdubray
May 29 2017 15:19 UTC
you mean with vuex?
I was trying to use vue.js only
looks like the lifecycle is something you can mess with
Daniel Neveux
@dagatsoin
May 29 2017 15:34 UTC
yes with vuex.
NextTick is just after the DOM update, it is not what you need.
Jean-Jacques Dubray
@jdubray
May 29 2017 15:34 UTC
sorry, it was another problem :=(
it's working now
Daniel Neveux
@dagatsoin
May 29 2017 15:34 UTC
Did you try to modify an observed data.property in you callback
k
Jean-Jacques Dubray
@jdubray
May 29 2017 15:37 UTC
I was incrementing the counter instead of decrementing :-P
It works as advertised, no need to use vuex
Jean-Jacques Dubray
@jdubray
May 29 2017 15:47 UTC
I still don't like templates, but what can I do?
Gunar Gessner
@gunar
May 29 2017 18:09 UTC
@jdubray On the square top-right, should not there be an arrow from the Model (inside Services) to the State?
Jean-Jacques Dubray
@jdubray
May 29 2017 19:11 UTC
it really depends on how you wire it, logically yes of course, this is a physical wire where the dispatcher gets a response that it forwards to the state.
Gunar Gessner
@gunar
May 29 2017 19:38 UTC
makes sense
Jean-Jacques Dubray
@jdubray
May 29 2017 22:04 UTC
That post just came up on InfoQ, I'd argue that a SAM+SAM based application architecture is a way to create modular code and avoid falling into the "big-ball-of-mud" https://www.infoq.com/news/2017/05/microservices-modularity