These are chat archives for jdubray/sam
render, the actions call
acceptand so on. Instead of having actions being pure functions returning a proposal, accept mutating the state, etc, and an external loop calling each of these function in turn as in
State( Model.present( Action( event ))). then( nap )
Sorry to be a contrarian, but there are two points of view you can adopt for the route:
I believe a route is an action, not a pointer. There is no "pointer" in SAM. You should not add semantics arbitrarily because it looks cool or seem to address a particular use case. Breaking semantics should be done with great care and my experience is that you always end up in a corner and you regret making that choice.
@jdubray I wouldn't say you are a contrarian. I think you are correct in your statement of the two possible approaches of routing, and I agree with your point of view. I have been considering routing lately and have also come to the conclusion that treating routing as an action is a much better design than trying to have a router as a source of truth. A route change becomes an action much like any other action, and the rest of the code works the same.
A different way of putting it is that most of your application should be the same with or without routes. You could add routes as an additional way to trigger actions, but then you should also be able to remove routing without much impact on the rest of your application. This goes back to the tweet you posted, saying "make your code easy to delete".
The author of router5 says the same thing in his presentation -- routes should be actions. (I find router5 itself to be too complex, too much setup and moving parts to align to get it working, but that's just my personal opinion.)
You could add routes as an additional way to trigger actions
yes, it's ok to use as "pointers" too, but it's really an action that results in a repeatable state, even though it looks like a pointer, it is not.
- synchronous req/resp: NAP has limited use, only synchronous (you can run an additional action before you return the response)
- one day everything will be asynchronous and we will no longer use HTTP1,2,3,4,5... because, well ...you know... the world is not just resource-oriented and nobody really cares about the hyper part, that day we'll use proper protocols such as Websocket and in that case we'll nap all we want.
I think in case when you need to send an email or sms for example:
Or actions like this should be responsibility of another part?