These are chat archives for jdubray/sam

8th
Mar 2016
Stardrive Engineering
@HighOnDrive
Mar 08 2016 00:15
@jdubray LOL, Observables are indeed the VERY BEST way to wire the pattern, but yeah you do need something to GUIDE the reactive loop of staged Observables. I'm guiding the reactive loop and repurposing it via a declarative configuration that defines a set of distinct control states that also "check if the action is allowed or not" among many more things.
Jean-Jacques Dubray
@jdubray
Mar 08 2016 00:29
Happy to learn, it does not look obvious.
Michael Solovyov
@msolovyov
Mar 08 2016 00:58
"Once you wrap your head around the SAM pattern you realize how easy decoupled reactive interfaces can be built.
"
Stardrive Engineering
@HighOnDrive
Mar 08 2016 00:58
It has nothing to do with Observables or SAM or MVI. Just my own practical solution that came out of building a larger app. I'm way to tired right now to convey it properly but hopefully I'll find time to do so soon.
Michael Solovyov
@msolovyov
Mar 08 2016 00:58
Er grammar error.
Once you wrap your head around the SAM pattern you realize how easy it is to build decoupled reactive interfaces.
Is that the type of quote you want or something else?
Jean-Jacques Dubray
@jdubray
Mar 08 2016 03:51
@msolovyov yes, perhaps just elaborating what you mean by decoupled ?
Michael Solovyov
@msolovyov
Mar 08 2016 06:24
Once you wrap your head around the SAM pattern you realize
I'll think of a better one tomorrow morning :)
weepy
@weepy
Mar 08 2016 15:30
That's what I thought about MobX
you should make it more explicit in your docs
so to be clear, SAM is just a pattern ? There's no library code etc ?
Jean-Jacques Dubray
@jdubray
Mar 08 2016 17:37
yes, 100% pattern, no libraries, but at the same time, it shows that you need little or no libraries at all (should you choose to) or you can implement your pattern with your favorite library.
I tend to provide samples with no libraries at all, so people can understand how the pattern works, then adapt it to their particular environment
For instance React.js is a good way to implement the components of the View.
We are getting ready to publish an angular sample that was built with Bruno Darrigues
weepy
@weepy
Mar 08 2016 19:45
Makes a lot of sense :-)
Be interesting to see how it works with riot.js
Jean-Jacques Dubray
@jdubray
Mar 08 2016 20:23

From Riot's docs

“Reactive” views for building user interfaces

as long as it is "reactive" it should be easy to implement. I'll try to take a look this week.

weepy
@weepy
Mar 08 2016 22:04
lovely !
weepy
@weepy
Mar 08 2016 22:12
so you have a repo timetravel
is this again just an example of how it could work rather than a definitive way
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:13
We are aiming at something more definition that you can plug in any kind of implementation
weepy
@weepy
Mar 08 2016 22:13
quite sweet
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:13
The big difference with React/Redux is that we are server friendly
weepy
@weepy
Mar 08 2016 22:13
you go at lengths to say that State doesn't refer to the typically meaning
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:14
TimeTravel will also have a server component
weepy
@weepy
Mar 08 2016 22:14
but you don't really say what it is !
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:14
well, it depends on your perspective.
We'll I think I do, it's "control state", things like your car is started/stopped
The "state" is a function of the property values
State generally refers to ranges of property values
weepy
@weepy
Mar 08 2016 22:15
so State <=> Store ?
in flux terminolofy
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:15
e.g. started = RPM_MAX > rpm > 0
weepy
@weepy
Mar 08 2016 22:16
so its not the state of the system
State = { started: true }
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:16
Again, it depends on your perspective
but see, that's not how it works, that's the problem
started = RPM_MAX > rpm > 0
weepy
@weepy
Mar 08 2016 22:16
hmm unfortanately i don't know what my perspective is !
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:17
in general, people stop at state = list of property values
weepy
@weepy
Mar 08 2016 22:17
yes
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:17
"State" control the actions you can take on a system
If a glass is empty I can't drink from it
without the understanding of the (control) states of the systems you can take the wrong decisions
weepy
@weepy
Mar 08 2016 22:17
so
state.canDrink = (data) => !data.empty
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:18
yes, exactly
weepy
@weepy
Mar 08 2016 22:19
so State <=> list Of functions that determine allowed actions
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:19
You cannot reduce control state to a boolean for complex systems
think of a rocket ship, to reach the "readyToLaunch" state, a lot of parameters must at nominal values / ranges
weepy
@weepy
Mar 08 2016 22:20
right i can see that
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:20
The State will also help compute the next-action predicate, i.e. an automatic action that happens when you reach a particular control state
that's important because in general people don't know where to put that logic
The big advantage of SAM is that it truly help you create logic-free views
weepy
@weepy
Mar 08 2016 22:21
yes i like nap
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:21
It's not magical, it's simply that State and View (State Representation) work together in lockstep
weepy
@weepy
Mar 08 2016 22:22
sideEffects are a bit lame in RE/FLUX
yes but State is more constrained that a Store
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:23
Yes, React is stuck with its architecture: once the model update you have to render the view
They really don't play the same role
weepy
@weepy
Mar 08 2016 22:23
yes
i just mean that the Entropy of a Store is larger
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:23
The problem with React's architecture is that you have to update the store in one shot, that's why Redux is a pure function of State (the other State, what I call the Model)
weepy
@weepy
Mar 08 2016 22:24
do you believe in 1 model ?
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:24
But that's just React's architecture, that creates a really bad coupling because the "Store" masks the "state". You have now to move the State computation into the View component (looks bad to me)
weepy
@weepy
Mar 08 2016 22:24
i.e. how to componentize
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:25
Yes absolutely, 1 model (or several independent models) is really the way to go
weepy
@weepy
Mar 08 2016 22:25
1 model or many ? lol
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:25
of course the model is hierarchical that you would not have a blob of code
1 model
weepy
@weepy
Mar 08 2016 22:26
so if u had several components
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:26
I say independent because some times, you can partition your application state, but in general it's one model
weepy
@weepy
Mar 08 2016 22:26
you would want to register them on a global model
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:26
The State does that in SAM
weepy
@weepy
Mar 08 2016 22:26
i see
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:26
the Model knows nothing about the View, the View/Components know nothing about the model
The react architecture is flawed.
React has a lot of fantastic ideas, but is it just a little bit wrong
weepy
@weepy
Mar 08 2016 22:27
mmm
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:27
As a result it creates some horrific coupling
weepy
@weepy
Mar 08 2016 22:27
its refreshing to see vanilla JS
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:27
YES!!!
weepy
@weepy
Mar 08 2016 22:27
love the use of HTML strings ! So basic, but they work
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:27
I can replace React with one line of code
weepy
@weepy
Mar 08 2016 22:28
i'm writing a fairly large app with many parts ... just wondering how one goes about componentizing SAM
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:28
I am not necessarily advocating to always do that, but SAM resets the skills you need to build beautiful web apps
weepy
@weepy
Mar 08 2016 22:28
no i get it
just means simpler for explaining
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:28
Happy to share some code samples privately (I am not the best coder)
SAM also allows to use all the HTML5/CSS3 features
Which most frameworks tend to obfuscates
weepy
@weepy
Mar 08 2016 22:30
m
this is what im building
it uses PixiJS
any thoughts on how that could be incorporated
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:31
I can see why you like nap() ... this is wonderful, really like it
weepy
@weepy
Mar 08 2016 22:33
thanks
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:33
I can see how SAM would implement the underlying business logic, there would be two views managed by the State (display and music)
what's interesting is that the actions have a time length
weepy
@weepy
Mar 08 2016 22:35
the music is all calculated in C
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:35
I would render the display animations as part of the view, outside of SAM
weepy
@weepy
Mar 08 2016 22:35
yeah
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:36
what is the input? are you calling functions to compute the music?
It looks like you could build the actions as "touch down" "touch up" events, that would update the model nicely.
can you express music = f(model)?
weepy
@weepy
Mar 08 2016 22:39
hm not sur
it is complicated ...
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:39
pixi.js sounds like it 's a good candidate for V = f(M)
weepy
@weepy
Mar 08 2016 22:39
there's cuing events
yes i think it would be
Jean-Jacques Dubray
@jdubray
Mar 08 2016 22:41
At a minimum you could use SAM for the display and handle the music separately.
You would have nice check-points at the State level to get notified of model changes
For the view, I have to assume that you'll have to update each element (~component) individually as it would not be practical to redraw the entire view after each action.
weepy
@weepy
Mar 08 2016 23:11
yes you just do sprite.x = 100
and boom
quite easy
anyhow i gotta go to bed!
good chatting