These are chat archives for jdubray/sam

26th
Apr 2018
Jean-Jacques Dubray
@jdubray
Apr 26 2018 01:24
In theory only actions can invoke APIs, in practice depending on the UX, commands are often synchronous (the user is not expecting to do anything until the command has completed), so it's ok to invoke commands in the model, in that case you may or may not complete the SAM loop until the command returns.
SAM allows to reduce the application architecture from a 6 layer model to a 4 layer model because Actions and Model are aligned with APIs and Services:
Jean-Jacques Dubray
@jdubray
Apr 26 2018 01:30
SAM allows you to write code that is 100% isomorphic and move elements of the pattern at any time without any refactoring other than a simple dispatcher. You can even use OAuth to integrate 3rd party actions.
Jean-Jacques Dubray
@jdubray
Apr 26 2018 01:45

So my idea for purely frontend projects that are totally decoupled from a backend

yes, this is how people should think of it and SAM really helps here because the State Representation and View never see the electrons of an API call, all API calls are hidden by actions (and the model for commands) and therefore, there is no notion of databinding. The problem is that in general front-end developers demand that APIs map to their views, SAM eliminates that discussion.

@jshrt You should also take a look at SAM-SAFE a microcontainer for SAM which shows for instance how to use SAM on the server with a session, as well as use SAM to implement a generic "cancel API call" approach.
SAM is also extremely well aligned with the Paxos protocol so the same pattern can be used for complex distributed systems as well.