These are chat archives for jdubray/sam

10th
Jun 2016
Edward Mulraney
@edmulraney
Jun 10 2016 08:07
The person that asked the question isn't using redux correctly
redux's state becomes very useful in that scenario because now, both blog posts exists in app state, and the user will only see the most recent one he clicked (the one he is interested in) - despite it taking longer to fetch than the first one he clicked
(as Dan Abramov describes)
This message was deleted
Jean-Jacques Dubray
@jdubray
Jun 10 2016 08:24
well, what if the two queries are unrelated? one is about a post the other about getting author information?
Edward Mulraney
@edmulraney
Jun 10 2016 08:27
is it important which resolves first?
Jean-Jacques Dubray
@jdubray
Jun 10 2016 08:29
It's a bit confusing for users because they know which order they asked... especially if app uses a commong area? (my question is not innocent since PAL enables a generic mechanism to solve that problem with SAFE)
Edward Mulraney
@edmulraney
Jun 10 2016 08:43
Interesting - so if I'm a user and I request a blog post, and before it resolves, I click the an author's name. I would expect to see the author's name page no?
That's how standard navigation works on websites currently
Jean-Jacques Dubray
@jdubray
Jun 10 2016 08:45
I meant, you are on a view where you see a blog lists and you ask for some details, you can see the post details or the author's details. You click on post, then you change your mind, you click on author, wouldn't you expect to always see the results of your last request?
Edward Mulraney
@edmulraney
Jun 10 2016 08:47
yes - you'd want to see author
Jean-Jacques Dubray
@jdubray
Jun 10 2016 08:48
how would redux do that?
Edward Mulraney
@edmulraney
Jun 10 2016 08:52
the router displays last clicked
let me check
Edward Mulraney
@edmulraney
Jun 10 2016 09:03
it's hard to test in the app I have to hand because the page is rendered instantly and a progressive spinner is displayed in place of any content that isn't yet resolved
but it looks as if, if you navigate to somewhere different than your original intent, it will behave correctly
Jean-Jacques Dubray
@jdubray
Jun 10 2016 09:06
ok
Edward Mulraney
@edmulraney
Jun 10 2016 09:22
so is SAM/PAL partly about not trying to shape your API's to fit your views?
redux encourages that too. but at the cost of more http requests, or switching to graphql
Jean-Jacques Dubray
@jdubray
Jun 10 2016 09:28
Yes, this was my original intent, this is a consequence of V = f(M). All API calls are within Actions/Proposers or the Model/Acceptor.
the view never gets to call an API it publishes events/intents and it get generated reactively, there is not "inter-action" (request/response). That's the major step forward coming from reactive unidirectional data flows.
Edward Mulraney
@edmulraney
Jun 10 2016 09:31
That's right. The view can only publish an action to initiate a call to an API
Jean-Jacques Dubray
@jdubray
Jun 10 2016 09:33
I would not call that an action, it can only publish an intent to do something. The action/proposer is what does not work, not the data structure published by the view.
In particular you don't "transition" from an intent. You may have pass through actions, that just do nothing from the intent, but that's relatively rare, there is at a minimum some validation.
In TLA+/PAL the goal of the actions is to present the exact values the model needs to mutate too.
Edward Mulraney
@edmulraney
Jun 10 2016 09:35
the executed action? so the thing processing the result of the action?
Jean-Jacques Dubray
@jdubray
Jun 10 2016 09:36
the action processes the intent/request from the view
the view does not implement actions
Edward Mulraney
@edmulraney
Jun 10 2016 09:37
(I'm tring to map my mental model of redux to PAL) In redux the actions are only intents too. They are pure JS functions that return a description of an action. later on, when the user initiates an action (intent) the dispatcher then executes it
Jean-Jacques Dubray
@jdubray
Jun 10 2016 09:37
Edward Mulraney
@edmulraney
Jun 10 2016 09:39
I've read it, but it's not all clicked into place yet. I work better with real world examples, which is why I'm rewriting the SAM-todomvc and sam-redux samples
Jean-Jacques Dubray
@jdubray
Jun 10 2016 09:39
Did you look at David Fall's Tic-Tac-Toe implementation?
Edward Mulraney
@edmulraney
Jun 10 2016 09:39
Ah I havent seen this one yet
yes
that's a redux implementation of SAM
Edward Mulraney
@edmulraney
Jun 10 2016 09:42
this looks like a good example. thank you
Jean-Jacques Dubray
@jdubray
Jun 10 2016 09:44
yes, spectacular
Edward Mulraney
@edmulraney
Jun 10 2016 09:49
you're happy with this as a good implementation of SAM?
Jean-Jacques Dubray
@jdubray
Jun 10 2016 10:10
@edmulraney sorry, Dave moved the tic-tac-toe engine to a different repository
Edward Mulraney
@edmulraney
Jun 10 2016 10:10
i found it - reading it now :)
its good to see the engine separated
Jean-Jacques Dubray
@jdubray
Jun 10 2016 10:12
:-)
My point, the view components can be decoupled 100% from the business logic. I'd use that any day.
Edward Mulraney
@edmulraney
Jun 10 2016 10:23
yes its a great example of that
Jean-Jacques Dubray
@jdubray
Jun 10 2016 11:52

So continued building the angular2 app (based on Google Angular2 so called quick start), just a simple CRUD app in an HTML table 4 actions:

  • 17,000+ files
  • 141 Mb of stuff

not sure why people don't want to use vanilla.js

Edward Mulraney
@edmulraney
Jun 10 2016 13:57
its standard for a framework really
after getting it production ready (webpack etc.) it will only be a few files and few hundred KB
and obviously you get the benefit of not having to write your own framework, or having multiple people putting their own architecture style into the code base
vanilla makes sense for small projects, but as soon as they become mid-size you run into difficulty