These are chat archives for jdubray/sam

28th
Jan 2018
Dmitry
@agDmitry
Jan 28 2018 20:56

Hello. I use React and i have some questions regarding models:

  1. Can models have nested models?
  2. Should/can i write component-specific models?

I mostly read in english, writing is somewhat problematic, hope you understand me.

devin ivy
@devinivy
Jan 28 2018 21:14
@agDmitry i understand you! and yes, you may use composition to construct your model in parts. specific components of your UI may also want their own models. so, 1. yes and 2. yes :) i think this video made by @foxdonut illustrates a good method to do what you're asking about. https://www.youtube.com/watch?v=KJSM2uFDzDY
Dmitry
@agDmitry
Jan 28 2018 21:59
@devinivy thanks for awesome video (just finished watching it)! It seems to me that it actually covers most of my questions about state management.
Jean-Jacques Dubray
@jdubray
Jan 28 2018 22:04
@agDmitry The key (and difference with React) is that in SAM there is a many-to-many relationship between actions and acceptors (bits of the model that accept the action proposal and mutate the state). That decoupling (the model acceptors only look at the proposal and not the action type) drives cleaner, more robust code.
SAM instances can easily be composed in a parent/child relationship. Some of the child actions would present the proposal to the parent, nap can also be used (though I prefer the former).
Last, I am working on a component model where the component state is centralized in the model. A component would implement a SAM child instance, but it's model would remain centralized with the parent, but in a component-instance-specific section. That way you get the best of both world:
  • a centralized model which can access the overall application state to decide whether to accept or reject a proposal
  • component-specific actions, acceptors, reactors
Jean-Jacques Dubray
@jdubray
Jan 28 2018 22:39
@agDmitry Please not Meiosis couples actions with Model updates which, IMHO is an anti-pattern. Unless I am missing something.
devin ivy
@devinivy
Jan 28 2018 22:46
often with very simple examples actions and model updates look coupled/similar.