These are chat archives for jdubray/sam

2nd
Apr 2016
Jean-Jacques Dubray
@jdubray
Apr 02 2016 04:11
Really excited to announce that SAFE now supports "action hang back"
https://github.com/jdubray/sam-safe
With action hang back SAFE ensures that, in any given step, when more than one action is triggered, only one gets to modify the model, all the others are ignored
In the code sample, one of the actions simulates a long running behavior:
actions.save = (data,next) => {
    data.item = {title: data.title, description: data.description, id: data.id || ''} ;
    if (data.item.id !== '') {
        // simulate a slow save after
        // editing an item
        setTimeout(function() { 
            actions.present(data,next) ;
        }, 9000);
    }
    else {
        // proceed as normal when created a new item
        actions.present(data,next) ;
    }
    return false ;
} ;
When you modify a blog entry and you hit save, the action will present its data 9s later. When you hit cancel before the save action presents its values to the model, then the save action will not be able to present its values