These are chat archives for jdubray/sam

Oct 2016
Charles Rector
Oct 16 2016 02:34
time travel sounds great for diagnosing bugs. i will get there some day...
i just wrote a small app to help me start understanding SAM. you can fill in the blanks of a 2D scene
it will be interesting to grow it to add/remove/reorder layers etc.
from some other conversations i read in these gitter threads, someone complained about restoring text cursor when blasting DOM. that was indeed a little tricky
in the end, perhaps not THAT difficult. though i can have a greater level of respect for React folks figuring out how to solve that now
Charles Rector
Oct 16 2016 02:54
trying to think of ways to use the whole "surface area" of SAM so i can be familiar with all of them
e.g. i am not using nap() yet. perhaps for some animation it would be useful, like floating those clouds
Charles Rector
Oct 16 2016 03:02
i suppose that may be more suited to a requestAnimationFrame loop though, rather than an automatic action
Jean-Jacques Dubray
Oct 16 2016 06:31

That looks great! Did you see the fishing game sample (sorry that's pretty simple)?

I am using a function as "state representation" that is passed to the view. There is also a good usage of nap(). One big philosophical difference that you will not find in any framework is the focus on what are the authorized actions at any given time. You can see that in the the SAFE library where the State function returns the list of authorized actions in any given "state". With RxJs for instance you would end up managing subscriptions.

In the SAFE sample, I return the list of actions:
state.representation = function(model,next) {
    var representation = 'oops... something went wrong, the system is in an invalid state' ;

    if (state.ready(model)) {
        representation = state.view.ready(model, state.intents) ;

    state.display(representation,next) ;

    // return allowed actions
    return ['edit', 'save', 'delete', 'cancel'] ;
} ;
And the SAFE library enforces it by keeping track of "action instances" (it assigns a unique identifier per action per step):
safe.newStep = (uid,allowedActions) => {
    allowedActions = allowedActions || [ ] ;
    var k = 0 ;
    var step = { 
        stepid: uid , actions: => {
            var auid = uid + '_' + k++ ;
            return { action, uid: auid } ;   
    })  } ;

    safe.steps.push(step) ;'new step        :'+JSON.stringify(step)) ;
    return step ;
} ;
Jean-Jacques Dubray
Oct 16 2016 06:39
You can then do really interesting things in terms of action cancellation, action ordering (e.g. wait for an action even if another one was triggered...
Jean-Jacques Dubray
Oct 16 2016 06:45
@/all I was wondering if I could ask everyone a favor. I am trying to create a funding model to create SAM samples (just to be clear not for myself). There are a few really talented people who have asked me for work. I wish I could hire them myself, but I just don't have the means to fund creating SAM samples at scale.
So if you like SAM and you would want to see more sample produced, I'd like to ask you to "star" the SAM sample directory on github:, there is already 70 stars, and I need to get to 100 to be considered on opencollective
Jean-Jacques Dubray
Oct 16 2016 19:06
I have updated the Angular2 Rocket Launcher Sample (Dynamic Templates)