These are chat archives for jdubray/sam

22nd
Mar 2017
ford
@foxaal
Mar 22 2017 16:13
It would be good to understand things in terms of SAM, given that compact representation thereof: V = S( vm( M.present( A(data) ) ), nap(M)). My first question is what is angular's value add in terms of this rep of SAM. Does it plug into the equation?
ford
@foxaal
Mar 22 2017 17:07
I would argue that unless a library, or definable portion thereof, out there in the JavaScript ecosystem plugs into one of the functional components of SAM, it is useless in terms of SAM unless it can be re-factored accordingly. Not talking about lodash, which is more of a general purpose utility belt... Talking about angular, redux, react, etc.
Jean-Jacques Dubray
@jdubray
Mar 22 2017 17:08
Angular2 is a good fit for SAM, I just completed a big project for a Fortune 50 using both. The main value add for Angular2 is that SAM keeps all the app logic outside the framework (so when Angular4 comes around you don't have your app logic trapped into it)
SAM works a bit differently with Angular2 because you cannot use "functional HTML" aka V = f(M)
I implemented with just a regular pub/sub mechanism. The State function publishes property updates, and the Angular2 components subscribe to these changes
This ToDo example is very general you can implement all the Angular2 components that way:
https://github.com/jdubray/sam-samples/tree/master/angular2-admin-master-2.0.0/src/app/pages/dashboard/todo
I also implemented a "CRUD" app with some variants (dynamic and semi-dynamic templates) which is a bit closer to functional HTML.
https://bitbucket.org/jdubray/crud-sample-sam-angular2
Edward Mulraney
@edmulraney
Mar 22 2017 17:12
what benefit did you get from using Angular 2?
ford
@foxaal
Mar 22 2017 17:12
I don't know angular 2. I literally hated angular 1. Overloading HTML, yuk! A rude awakening from ES6 happy land.
ford
@foxaal
Mar 22 2017 17:17
OK, so you use "Angular 2, the good parts" which is just components. I will check out your link, but I hope I don't have to spend two weeks with Angular 2 to get an understanding. For the uninitiated, what is the mechanism for pub/sub? Is it some kind of websockets thing?
Jean-Jacques Dubray
@jdubray
Mar 22 2017 17:17
1/ Angular2 has a simple programming model when compared to react. You have zero choice to make.
2/ You don't have any cascading properties, stores, props/state whatever. It's all clean.
3/ Angular-cli takes all the burden of managing your code away
I am not a big fan of templates, I hope one day they replace them with a functional HTML approach
@foxaal To be really honest, there is not much to know about Angular2, it looks intimidating, but once you start using their programming model you see that it's a cookie cutter. It scales really nicely (in scope).
@foxaal just look at the todo sample, you'll see what I mean
ford
@foxaal
Mar 22 2017 17:20
Oki :) Will check it out.
Jean-Jacques Dubray
@jdubray
Mar 22 2017 17:21
The CRUD sample is more advanced and it won't add much, I don't think you need dynamic templates. I started that route because I don't like templates very much, but the result ends up to be ok.
The key though is to not use two-way data binding, only one way.
ford
@foxaal
Mar 22 2017 17:23
yes, I can see why two-way binding would be (is) a cluster! I thought they were getting rid of two-way for Angular 2... Will check it out when I get a chance. Thx!
Jean-Jacques Dubray
@jdubray
Mar 22 2017 17:31
Not really, it is still around, but they support one-way too
The key in SAM is that no other element of the programming model can mutate the model/application state. (Angular2) components trigger actions, which create proposals for the model to accept or reject.
So only the model can mutate the application state.
The state function is a pure function that translates the model/application state into properties the component subscribe to