These are chat archives for jdubray/sam

24th
Jan 2017
Slađan Ristić
@sladiri
Jan 24 2017 00:09
@jdubray Thank you for the refresher, in our company GraphQL was briefly introduced to us and I had your comments in mind.
Slađan Ristić
@sladiri
Jan 24 2017 01:44
One thing I am wondering, I just watched your video on samjs.org: If the state function must have completed before the next action may propose to the model:
Does that mean that the model has to pass a unique ID on each call of the state function? How could you ensure that each ID is only passed once? Blacklisting would mean an ever-growing list, I guess some cryptographic sequence would be a solution, where the model could compute if a an ID already came before the last ID for example? @jdubray
Jean-Jacques Dubray
@jdubray
Jan 24 2017 01:45
@sladiri Did you check SAFE? https://www.npmjs.com/package/sam-safe
It's not perfect but it keeps track of complete steps for you.
In general you don't need to. I can write a lot of apps without checking for a step id
When the next action is truly synchronous, it's ok to trigger it from the model without rendering the state. The general mechanism should be used however for asynch actions
Slađan Ristić
@sladiri
Jan 24 2017 01:50
I looked into SAFE a bit, I am actually implementing another version of it already I guess. I think in my case I can just use a timestamp, it is a bit too late to ask questions I guess. :) Am intentionally using asynchronous messaging actually, so I will keep this in mind.
Jean-Jacques Dubray
@jdubray
Jan 24 2017 01:56
You are not running into precision issues?
SAFE is a micro-container for the elements of the pattern. It primarily manages the StepID and the allowed actions (once you manage a bit of ancillary state, you might as well get the basics covered)
I think it's best to keep the step management outside the actions/model/state
Slađan Ristić
@sladiri
Jan 24 2017 13:36
I tried to apply SAM to a Polymer/Redux project:
https://github.com/dgoerdes/polymer-template/tree/feature/Redux_store_element
  • The computed-functions decouple the view from the model, I guess. (state-representation)
  • The reducer is not pure anymore, probably not much use of Redux itself but the dev-tools.
  • I added a thunk middleware just to try it out, but I do not see any benefit.
@jdubray I did not try out the timestamp, it could be too inprecise, yes. The step managment is outside, although I pass the required data through the SAM functions, because it is easier, and I do not have much time currently. So every action payload carries a token by the server, set after state-representation, where the stepID can be saved.
Jean-Jacques Dubray
@jdubray
Jan 24 2017 14:01
yes, that's pretty much how SAFE works