These are chat archives for jdubray/sam

19th
Oct 2016
Edward Mulraney
@edmulraney
Oct 19 2016 09:24
@jdubray my first assumption was also what you suggested about using state representation to calculate isModalOpen = false from isLoggedIn. but the problem with this approach is that the unit of state representation responsible for the Modal must now be aware of the logged in state, which really is not the modal's concern. i.e. this modal is now use-case specific and isnt necessarily reusable
Fred Daoud
@foxdonut
Oct 19 2016 12:16
@edmulraney I would argue that the state representation would be located in an area of the code where it makes sense to be aware of the logged in state, and the consequences, i.e. that the model should not be open. The modal itself is not tied to the logged in state, all it cares about is the isModelOpen flag to determine whether or not to display itself.
Edward Mulraney
@edmulraney
Oct 19 2016 12:38
you're right - the modal component itself only has the isOpen property, manipulated from some container or higher order component, which the Modal is unaware of
so state-representation is use-case specific, and has access to all model data. been a while since i played with SAM, forgot these things !
state representation is really no different to redux selectors
devin ivy
@devinivy
Oct 19 2016 12:41
exactly
(at its core) it's the same idea
in my experience that factoring is absolutely critical!
usually without that factoring it makes people muck-up the model so that the model data is easier to work with in views.
muck-up, meaning heavily denormalize or make it difficult to mutate.
i've seen this a bunch in practice.
devin ivy
@devinivy
Oct 19 2016 12:47
i must say, i really do like the non-state approach to opening/closing modal. i think that it's open/closedness is more related to the login action than the isLoggedIn state.
so i think that the model should react to the login intent/action. the reason i bring it up is because this happens without any actual proposal, so i'm not sure it's fully compatible with SAM "by the book".
for example, if login fails i might also want to close that modal and redirect the user to a "forgot password" page.
despite there being no proposal in that case, i should still be able to close the modal. and i don't think it should necessarily be closed by proposing isModalOpen: true. instead, the model should react to some LOGIN_FAIL intent which is not strictly a proposal of any specific changes to the model.
devin ivy
@devinivy
Oct 19 2016 12:53
what i'm saying is that i wonder if the model at times benefits from taking the reigns and deciding on some mutations itself.
Jean-Jacques Dubray
@jdubray
Oct 19 2016 13:08
@devinivy absolutely, this is not about the action proposing 100% of the mutation payload. You cannot expect the action to know everything about the model and the impact of the proposed values on the system. Just like when you propose a destination to an electric car, you have no understanding if it can be reached.
Edward Mulraney
@edmulraney
Oct 19 2016 13:12
@devinivy thats how ive been doing SAM proposals. i propose constants like you suggest LOGIN_FAIL, or DRAW_RECTANGLE, then the model decides how to mutate based on that constant
DRAW_RECTANGLE: {payload: {x1: 10, y1: 10, x2: 20, y2: 20}
in that proposal there is nothing about how the model should mutate, just a proposal of some co-ordinates for the model to do what it likes with
Jean-Jacques Dubray
@jdubray
Oct 19 2016 13:26
@edmulraney it really depends if that logic belongs to the model or not. The advantage of cogent actions (as opposed to anemic ~no business logic) is that there can be alternatives to it. Implementing these alternatives in the model is not ideal.
Edward Mulraney
@edmulraney
Oct 19 2016 13:27
exactly - if the logic requires access to app model data, the logic goes into the model. if the logic is self-sufficient, it goes in the action
Jean-Jacques Dubray
@jdubray
Oct 19 2016 13:30
You may also have application specific validation rules that would not fit well in the model
Fred Daoud
@foxdonut
Oct 19 2016 13:36
@devinivy @edmulraney @jdubray (or anyone else who has suggestions): what do you guys like to use for UI widgets (modals, autocomplete, datepicker, etc.)? Bootstrap, jQueryUI, material-ui, ... what are other options?
Edward Mulraney
@edmulraney
Oct 19 2016 13:39
material-ui and bootstrap, but often just custom css
Edward Mulraney
@edmulraney
Oct 19 2016 13:45
my last year of work (contracting) i used bootstrap, material-ui, custom css/components, and Ionic's own library
devin ivy
@devinivy
Oct 19 2016 13:45
@jdubray ah, okay! this is nice to hear aloud! i agree.
@foxdonut primarily material-ui these days
Fred Daoud
@foxdonut
Oct 19 2016 13:47
ok so specifically http://www.material-ui.com with React?
devin ivy
@devinivy
Oct 19 2016 13:48
yep!
before that i used polymer's paper elements for material. i don't get to do as much work in polymer these days :/
there's at least one more very popular material lib for react.
Fred Daoud
@foxdonut
Oct 19 2016 13:52
ok cool. thanks for the feedback!
I am using material-ui for my next Meiosis example, just wanted to have an idea if it was a good choice :)
devin ivy
@devinivy
Oct 19 2016 13:58
it's a good library. it has one flaw, which is that styling it is often cumbersome because of how they use inline styles. there are plenty of workarounds, though :)
Fred Daoud
@foxdonut
Oct 19 2016 14:07
@devinivy yes, it seemed that way to me. for example, I wanted to have vertical tabs, and could not find an option for it. however it's apparently feasible with custom styling, but I did not want to dive deep into that.
Jean-Jacques Dubray
@jdubray
Oct 19 2016 14:12
we struggled a bit to find a date picker that worked in Angular2
otherwise bootstrap, but we are building enterprise apps not customer apps
Fred Daoud
@foxdonut
Oct 19 2016 20:17
What's nice about material-ui is that it is declarative. So if the state representation produces inProgress: true | false and the view uses that value to display a "Please wait" modal, then it all fits in nicely. view = function(model). It even works with the tracer tool:
meiosis-in-progress.gif
Edward Mulraney
@edmulraney
Oct 19 2016 20:20
that looks cool :)
Jean-Jacques Dubray
@jdubray
Oct 19 2016 20:30
:+1:
Fred Daoud
@foxdonut
Oct 19 2016 23:22
@jdubray I read your article, that is an excellent assessment of the functional and reactive webapp programming landscape. Lots of great references too. Well done! 5 :star: :star: :star: :star: :star:
I hope lots of people read it and consider how elegantly SAM solves the issues that you outlined.
Jean-Jacques Dubray
@jdubray
Oct 19 2016 23:25
thank you!