These are chat archives for jdubray/sam

Jul 2016
Jean-Jacques Dubray
Jul 13 2016 02:48
This is a standard state machine, when the (action,target state) relation is static. There is no need to involve "application state mutations". In general that relation is not static but derived from once the model has accepted the action's proposal.
Note that even in that case, we might consider a non static relation where the container is configured to start/stop depending on what's running inside.
or ... outside.
Jean-Jacques Dubray
Jul 13 2016 14:57
very intersting performance results:
I guess we can forget Cycle.js and Ember
Was impressed with vanilla.js results
"Inferno.js is an incredibly fast framework and only 1.3 times slower than vanillajs, which is simply amazing."
This message was deleted
Vincent Jo
Jul 13 2016 15:58
holy crap ember is slow
I wonder where jquery would be
so I stayed up late evening last night to make Grunt-browserify AND Webpack work with SAM application I've been building
holy crap that was crazy
I was experimenting with grunt-browserify and webpack and to see which is better
I like grunt-browserify because it makes more sense when I'm configuring it
there was kind of a hack that I had to do though for SAM to work
which for intents, I had to do something like
window.intents = {
    ...list of intents... 
so that the onclick handlers would work
Vincent Jo
Jul 13 2016 16:04
by default, Webpack and Grunt-browserify wraps everything in a immediately invoked function
so anyone wanting help, I can send you the config files for reference... it was a lot of work to figure it out..
Edward Mulraney
Jul 13 2016 18:22
@chiwoojo I had to do the same "hack". I've started looking at alternatives but I don't think there are
devin ivy
Jul 13 2016 20:54
is it on window just so that it can be called in onclicks?
Vincent Jo
Jul 13 2016 21:59
@devinivy yea
I also had in mind to export that specific file to the global scope.. But now I'm thinking just attaching onto the window is the same thing
@edmulraney what app are you building now with SAM?
Jean-Jacques Dubray
Jul 13 2016 22:25
There are only two ways I know you can mount intents dynamically:
1/ as you did, though I use a variant:
        var actionsMount = {} ;
then during the instantiation (wiring):
// Mount SAM actions into the DOM
        actionsMount.actions = actions ;
2/ in the render method you can mount the actions to the view component. This is some code for angular2 but it will work with any component model
var vc : any = compileToComponent(sr[prop], [ChildComponent,CounterComponent,AutoGrowDirective]) ;

            // mount dispatcher by default
            vc.prototype.dispatch = (event: any) => {
                console.log('dispatching from view component') ;
                this.sam.actions.dispatch(event) ;
In this sample, the Angular2 component is compiled dynamically but that's irrelevant, what is important is vc.prototype.dispatch
Jean-Jacques Dubray
Jul 13 2016 22:31
In the view component I have a regular event handler:
<input  id="search" placeholder="Search..." autofocus autoGrow
                                #searchInput ${filterValue} (input)="${intents['search']}'id':'search','name':searchInput.value})"><br>` ;
Jean-Jacques Dubray
Jul 13 2016 22:56
The intent structure looks like this (mount = "actionsMount", the last intent will work invoke the dynamically added method):
intents: {
            edit: mount+'.actions.edit({',
            save: mount+'{',
            delete: mount+'.actions.delete({',
            filter: mount+'.actions.filter({',
            search: `dispatch({__action:'search',`
Jean-Jacques Dubray
Jul 13 2016 23:39
@chiwoojo the whole sample is available here:
The only reason why this is render is because the Angular2 component is dynamic, otherwise you can mount them in some init/laizy loading operation
Jean-Jacques Dubray
Jul 13 2016 23:51
I didn't publish this sample on Github yet because I was planning to clean it up.