These are chat archives for jdubray/sam

26th
Mar 2016
Jean-Jacques Dubray
@jdubray
Mar 26 2016 04:16
Mon article sur SAM a été traduit en Français http://www.infoq.com/fr/articles/no-more-mvc-frameworks
brusand
@brusand
Mar 26 2016 07:35
Super !:-)
brusand
@brusand
Mar 26 2016 16:07
C est beaucoup plus clair :)
Sorry french joke
Nihat
@nozer
Mar 26 2016 20:33
Do you store the error cases in model? If not then where? For example, you said: " For instance, we can define an action which will invoke a 3rd party validation service, which given an address, returns the postal address (or an error). It is then the postal address which is presented to the model." What if an error is returned? Would I present this to the model and set some variable there to indicate this erroneous situation (which can be reflected in the view during state representation)?
And thank you for the great write-up about SAM!
weepy
@weepy
Mar 26 2016 20:39
One question I had was how to work with componentization and SAM?
brusand
@brusand
Mar 26 2016 20:42
Weepy personnaly i use typescript see m'y github sample (sam type script un thé sample list
M'y 2 cents
Nihat
@nozer
Mar 26 2016 20:44
weepy, I am still learning but Mr Dubray was saying in his write-up that , for view, react components without state could be used. so, that could be one of your componentization strategy
weepy
@weepy
Mar 26 2016 21:11
Sorry I should explain better.
So say I have a large app with 20 different full pages. Each page has roughly 5 different types of sub module some of which are shared across the project.
Obviously I want to be able to run/test each of these pages and sub modules separately in isolation.
But I also want to run them together. How to achieve this ?
Nihat
@nozer
Mar 26 2016 21:14
Here are some ideas from top of my head...
since the model in SAM is the ultimate place to derive state and produce its representation (its view), i guess one could make model mockups to produce all possible states. For each model mockup representing a particular state, one could examine the state representation (view) for existence of specific tags or strings to check its validity
weepy
@weepy
Mar 26 2016 21:22
I guess the question I'm asking is "does Sam compose
Nihat
@nozer
Mar 26 2016 21:23
I don't know. I am looking forward to seeing what Jean will have to say.
Jean-Jacques Dubray
@jdubray
Mar 26 2016 21:29
Yes, there are multiple levels of composition
there is a whole section on composition here: http://sam.js.org/#comp
If you have specific questions I am happy to answer them
Nihat
@nozer
Mar 26 2016 21:32
I had a question above starting with: "Do you store the error cases in mode.. ". Will you please take a look at it
?
Jean-Jacques Dubray
@jdubray
Mar 26 2016 21:33
Would I present this to the model and set some variable there to indicate this erroneous situation (which can be reflected in the view during state representation)?
Nihat
@nozer
Mar 26 2016 21:34
Yes, that is my question
Jean-Jacques Dubray
@jdubray
Mar 26 2016 21:34
yes, there is no way around it, like in React the model must hold the state and the view must render it
this is no different than react
Nihat
@nozer
Mar 26 2016 21:35
Thank you
Jean-Jacques Dubray
@jdubray
Mar 26 2016 21:35
sometimes it looks a bit odd we are use to "error handling", while here this is just another representation of the model
Nihat
@nozer
Mar 26 2016 21:35
true
same for loading indicators
weepy
@weepy
Mar 26 2016 21:35
I had a look at the composition part of the website. Sorry I don't really follow - don't know the maths particularly. I'm just trying to figure out how to handle componentization
Jean-Jacques Dubray
@jdubray
Mar 26 2016 21:35
yes, it's all about state / state representation
Nihat
@nozer
Mar 26 2016 21:35
assuming our address check will be done on server, i guess b4 making the request, we present data to model to indicate "checkingaddress=true"
Jean-Jacques Dubray
@jdubray
Mar 26 2016 21:35
Note that you have opportunities to act on the error with nap()
yes, that's one of the key benefit of SAM, we don't couple that call to the mutation, unlike Redux
Nihat
@nozer
Mar 26 2016 21:37
digesting the "opportunities to act on the error with nap()"
Jean-Jacques Dubray
@jdubray
Mar 26 2016 21:37
You could also decide to present a completely different response to the error (e.g. show a list of potential addresses)
The problem with error handling is that it can quickly become messy
You have two cases:
1) nothing to do, just display the error
2) display and do some clean up (call another action)
2) is the hard case because it can influence the resulting application state
Nihat
@nozer
Mar 26 2016 21:39
i think reason etc will be easy if we have a place in the model tree for all error cases
so, i see how sam makes it easy to deal with
there is a flow and clarity
Jean-Jacques Dubray
@jdubray
Mar 26 2016 21:40
SAM makes a clear distinction between "actions" (that you take in response to the error) they belong in nap() not in the model
don't know the maths particularly. I'm just trying to figure out how to handle componentization
it's just function composition for the UI
@weepy In theory you start with one big function, which is composed of multiple "components"
weepy
@weepy
Mar 26 2016 21:44
I see
Jean-Jacques Dubray
@jdubray
Mar 26 2016 21:46
There is a full example of componentizing the view here:
http://sam.js.org/#getstarted
Nihat
@nozer
Mar 26 2016 21:46
@jdubray this is confusing: SAM makes a clear distinction between "actions" (that you take in response to the error) they belong in nap() not in the model
Nihat
@nozer
Mar 26 2016 21:47
i see that actions present data to model, model calls state to render itself and state calls nextaction
Jean-Jacques Dubray
@jdubray
Mar 26 2016 21:47
Sorry, to many parallel discussion, and it's 3 am for me right now
Nihat
@nozer
Mar 26 2016 21:48
so if there is any error in action, i must put it somewhere in model so that it can be represented in the next "erroneous" state on view.. i don't understand how nap relates here..
understand, sorry!
Jean-Jacques Dubray
@jdubray
Mar 26 2016 21:48
yes, in other words the processing of the exception can take two paths:
1) simple mutation, the model records the exception and get ready for rendering
2) you are in an "exception" state, something unexpected and you need to do some clean up as a result
Nihat
@nozer
Mar 26 2016 21:49
oh yes, i was just imagining i showed user the error on this erroneous state and user will do something to fix.. u are speaking in general.. understood
Jean-Jacques Dubray
@jdubray
Mar 26 2016 21:49
you should not call the clean up actions from the model, they should be called in nap() as a result of being in the corresponding exception state
Nihat
@nozer
Mar 26 2016 21:50
yes, i understand
thank you; that will be all from me for now
Jean-Jacques Dubray
@jdubray
Mar 26 2016 21:50
ok
Fred Daoud
@foxdonut
Mar 26 2016 22:20
@gunar hello, I am trying your counter example with time travel from https://github.com/sam-js/sam-devtools but it only shows the series of steps in the sidebar, clicking on them doesn't do anything. how do you time travel/go back in time? thanks
Gunar C. Gessner
@gunar
Mar 26 2016 23:35
@foxdonut this is how it's supposed to work. are you sure your aren't clicking a state where nap happens? if then, it'd seem as nothing had happened.
you*
also, you cold try and take a look at the console log as to give me a hint of what's (not) happening
could*