These are chat archives for jdubray/sam

Jun 2017
Viktor Yakubiv
Jun 01 2017 09:45
Johan AlkstÄl
Jun 01 2017 09:51
Viktor Yakubiv
Jun 01 2017 09:57
I'm implementing service with SAM. I have chosen pure ECMA Script 2015 implementation to get better understanding of how SAM works.
I need to make several REST queries and download all necessary data. But I have dependencies between data objects, and can fetch next object after all it dependencies were accepted by model. But here is a problem.
To my mind, fetching data from RESTful service, preprocessing it to make a proposal to model is the action-side job. But if I have resolved more than one dependency, in action side fetching and proposal will be made more times. So I should control which requests were made, and which were not. But this is model's job.
I understand why, and agree that CRUD operations should be in the model, but it makes me confused how implement it with model if in this situation next fetching of data should be computed by next-action predicate, which is part of state.
Jean-Jacques Dubray
Jun 01 2017 12:36
@viktor-yakubiv You have several options
1/ fetch all the data you need in the actions and make one big proposal (I think that does not work for your use case)
2/ fetch the data from the action and present a proposal after each response (but that's not too different from the first one, you could render intermediary results to the user). This is an optimization of "nap", you know the next action, fetch more data, so there is no need to have it done by nap
3/ in the case the decision of fetching more data is made by the model or you need some additional data from the model to continue fetching, then you have to use the next-action-predicate to trigger an additional fetch data action. This results in creating "ancillary state machine" to help you manage the state you are in (requiring-more-data, fetching-data, got-data).
Hope this helps
Jean-Jacques Dubray
Jun 01 2017 12:43

In the data function you'll have a state predicate like:

     needMoreData = (model.dataset1 !== undefined) && (model.dataset2 === undefined) || (model.dataset2 !== undefined) && (model.dataset3 === undefined)

then in nap():

    (model.dataset2 === undefined) ? fetchDataset2(somePropsFromTheModel) 
  : (model.dataset3 === undefined) ? fetchDataset3(someOtherProps)
  : done()
Marcus Feitoza
Jun 01 2017 16:22
@jdubray why do you not create a GitHub repo for SAM documentation and create a GitHub Pages with the current theDocs or
Will be more easy to everyone contribute. I think there a lot of good insights and thoughts here but not in docs.
Gunar C. Gessner
Jun 01 2017 16:38
@mfeitoza you can always send PRs to
which is
Marcus Feitoza
Jun 01 2017 16:47
Ooh thank you, I have not seen.
But I think will be better if the docs could be writing in MARKDOWN instead of pure html.
Jean-Jacques Dubray
Jun 01 2017 16:49
yes, correct, alternatively we can start having discussions on StackOverflow
It's hard to have a structured (as in wiki structured) set of discussions
@viktor-yakubiv Do you want to ask the question on
Gunar C. Gessner
Jun 01 2017 16:57
We could use GitHub's native Wiki
Jean-Jacques Dubray
Jun 01 2017 17:48
I added a Wiki to the project: if you guys want to try it.
It prefer StackOverflow because of the discussion aspects.
Daniel Neveux
Jun 01 2017 20:31
+1 to stack overflow. For once I will have something to say rather to ask!