by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Jean-Jacques Dubray
    @jdubray
    The react component model itself does not offer a good way to close the loop that's why they ended up adding Flux/Redux, then Thunks then Sagas, then GraphQL, then Relay...
    that's a bit too much, if they had started with v = f(d) (and JSX) they probably would have created something that was 99% simpler.
    You also see from his presentation that stream don't really add much to the architecture:
    v$ = f(d$) or v[] = f( d[] ) does not change anything, just some wiring.
    IMHO, react is out of control
    Esteban Negri
    @enbits
    That's what confusing me lately. Seems like the big ones (I mean, Google, Facebook, etc) doesn't know what to do. I'm pretty new at these Javascript frameworks and I wanted to use Angular as a base for all future developments, but with all this Angular 2 ramble I'm really lost and I thought it was just me, then found your article.
    And PHP frameworks keep working with MVC so that adds more confusion when people talk about using Angular + Laravel to build apps
    Jean-Jacques Dubray
    @jdubray
    They sure don't make it easy. I say SAM gives you a good enough structure to start with, you can choose how much framework you really need on top of that.
    For the sad part is all these frameworks tend to obscure the value of HTML5/CSS3 because they want you to use plain vanilla HTML
    Esteban Negri
    @enbits
    Well I like minimal stuff and Angular is a monster, never understood V1. So what are the key js libs that I should use if I want to implement SAM?
    Gunar Gessner
    @gunar
    You don't need absolutely any lib to implement SAM. That's the beauty of it.
    That being said, I like myself some React (or any other VirtualDOM lib) for the View.
    NB: There is no V in SAM, so it's really a matter of taste and doesn't change anything.
    Jean-Jacques Dubray
    @jdubray
    +1, you can use anything for V, Stateless React Component I believe are pretty good. You can take a look at the sample list: http://sam.js.org/#rocket
    Esteban Negri
    @enbits
    Thanks guys!
    Aliaksei Kuncevič
    @kuncevic
    This message was deleted
    dnson
    @imnutz

    @jdubray my another attempt using SAM to build webapp :relieved:
    https://github.com/imnutz/dashboard

    In this, I tried to split the webapp into folders and components.
    May you take a look?

    Jean-Jacques Dubray
    @jdubray
    sure, you are amazing! thank you for all your contributions.
    Jean-Jacques Dubray
    @jdubray
    the actions are about validating and enriching
    It looks great except for one thing, I would not put the CRUD operations (services) in the actions and call these actions from nap(). Logically this is truly what happens but IMHO, it is better when the model persists its values
    There could be some race conditions that occur when you handle the persistence with nap()
    dnson
    @imnutz
    @jdubray so from what you said, there should be some thing like this in the model:
    model.fetchingData = function() {
          callRestAPI({})
               .then(function(response) {
                      - update model's data
                      - call State.render
              })
    }
    
    model.updateContact = function() {
          callRestAPI({})
               .then(function(response) {
                       - update model's data
                       - call State.render
               })
    }
    
    // same for create and delete
    Jean-Jacques Dubray
    @jdubray
    Yes, but this is called from within the model, not the actions.
    the rationale is that there is no point in rendering the view until the model has persisted and the persistence layer has also accepted the values of the model. If you could be guaranteed that whatever value has been accepted by the model will persist as is, then you could use actions in nap().
    the other aspect to consider is concurrency. As soon as actions can be triggered and processed before the present model has completed, then you will run into concurrency issues. The SAFE middleware "blocks" the present method and serializes all action execution, in particular it would check for the "allowedActions" in the new State before processing an action waiting in the queue.
    Jean-Jacques Dubray
    @jdubray
    I believe that's the problem with React, the reducer could technically process more than one action, then depending which one finishes first would be immediately overwritten by the last one.
    You have to always ask the concurrency question when you build such a system.
    dnson
    @imnutz
    @jdubray thank you for reviewing and explaining this.
    Jean-Jacques Dubray
    @jdubray
    you are welcome, again happy to discuss better alternatives, this is a very important question
    tomorrownull
    @tomorrownull
    m
    Bang-Equal
    @Bang-Equal
    I am trying to run the crud-blog but none of the button clicks work because "actions is not defined". I dopn'
    I don't see actions in server.js but I do see it in blog.js
    Jean-Jacques Dubray
    @jdubray
    @ReketeBravo could try that repo? https://github.com/jdubray/sam-safe
    Did you do npm install?
    Bang-Equal
    @Bang-Equal
    yes
    Jean-Jacques Dubray
    @jdubray
    I just tried it on my machine and it seems to work
    Let me check if I pushed the latest code
    Looks like the latest code is available in the repo
    Bang-Equal
    @Bang-Equal
    is it correct that server.js does not have actions?
    Jean-Jacques Dubray
    @jdubray
    yes, I implemented the actions in the browser, SAM allows to decide where the elements of the pattern are deployed
    Bang-Equal
    @Bang-Equal
    ok, I am currently running node on a Win7 machine
    let me try on my macbook
    Jean-Jacques Dubray
    @jdubray
    This particular sample "presents" the results from the action to the model
    // server side $.post( "http://localhost:5425/app/v1/present", data) .done(function( representation ) { $( "#representation" ).html( representation ); } );
    which line is the error?
    Is the error on the server?
    Bang-Equal
    @Bang-Equal
    no the error was in the browser, the click handler for the button was saying action was undefined
    Jean-Jacques Dubray
    @jdubray
    I am need to go to a meeting, but I would check in the Web console what is coming back from the server:
    .done(function( representation ) {
                    $( "#representation" ).html( representation );
                }
    Bang-Equal
    @Bang-Equal
    ok, thank you
    Jean-Jacques Dubray
    @jdubray
    The HTML should be wired to the blog.js actions. If you look in blog.js it should look like this:
    var actions = {} ;
    
    actions.edit = function(data) {
        data.lastEdited = {title: data.title,  description: data.description, id: data.id } ;
        present(data) ;
        return false ;
    } ;
    
    actions.save = function(data) {
        data.item = {title: data.title, description: data.description, id: data.id || null} ;
        present(data) ;
        return false ;
    } ;
    
    actions.delete = function(data) {
        data = {deletedItemId: data.id} ;
        present(data) ;
        return false ;
    } ;
    
    actions.cancel = function(data) {
        present(data) ;
        return false ;
    } ;
    You can also run the sample without a server, you should uncomment the client code and comment the server code
    Bang-Equal
    @Bang-Equal
    I will try
    Jean-Jacques Dubray
    @jdubray
    For instance, in blog.html:
    // client side
                model.present(data) ;
    
                // server side
                //$.post( "http://localhost:5425/app/v1/present", data) 
                //.done(function( representation ) {
                //    $( "#representation" ).html( representation );
                //}        
                //);