These are chat archives for jdubray/sam-examples

16th
Feb 2016
Michael Solovyov
@msolovyov
Feb 16 2016 02:33
here's my attempt at the list app, http://codepen.io/msolovyov/pen/qbvYpv?editors=1010
I needed to add a state for when we're editing as opposed to adding
Jean-Jacques Dubray
@jdubray
Feb 16 2016 02:45
thank you Michael. Yes that works, I like states :-)
That being said, I also wanted to show that the pattern does not degrade too much when you don't use them. I understand that State Machine semantics can translate into very verbose code and I'd trade state for the delineation of business logic into actions, model and next-action-predicate without second thoughts.
Jean-Jacques Dubray
@jdubray
Feb 16 2016 02:50
As we talked before, I understand your reservations about my silly string concatenations, but I feel a lot better when I don't use templates and databinding, they tend to erode the intent of the patent that the View is a function of the Model. It you absolutely have to use a framework, I would prefer something like React or Cycle.js
In the end I just want to show that you can build great looking Web apps without a framework. As I mentioned before, the ngrx list app, took nearly 10 minutes to install on my Mac (npm install)
Gunar C. Gessner
@gunar
Feb 16 2016 02:56
who calls the nap function and when?
Jean-Jacques Dubray
@jdubray
Feb 16 2016 03:00
The state object/element, after the state representation (aka the view) has been rendered
This is where you could serialize actions when needed, for instance the counter example I keep coming up with does not work when concurrent actions are expected (you'd be presenting stale values)
You can only execute one action at a time (on a given model) and all the others have to be queued. When you are dealing with a typical GUI and only the user can send actions, you block the even loop until the new state representation is rendered (or if you don't want to block, you queue it up in nap())
Jean-Jacques Dubray
@jdubray
Feb 16 2016 03:08
unlike what Mykola Bilokonsky (@mbilokonsky) was saying, to separate actions from model is not an anti-pattern at all (how would it be?), however, if you don't have the nap() function, you'd run concurrency issues. Again, this is standard TLA+ regardless of what @brucou is saying.
Michael Solovyov
@msolovyov
Feb 16 2016 04:18
Thanks for your input. I understand that it's not hard coded relationship and it's up to the developer to keep the code strict to follow sam dataflow. This was also a way for me to learn vue.js. I'll give react and cycle a try for the same examples and see how they fare. In vue.js it's pretty easy to make the view be based off state exposing different actions which I liked.
Michael Solovyov
@msolovyov
Feb 16 2016 04:29
I'll be looking for a pattern or abstraction to make the model.present code cleaner, something without all those if statements
maybe the command pattern