1. #11
    Ext Premium Member Jan (HL)'s Avatar
    Join Date
    Aug 2010
    Location
    Germany
    Posts
    96
    Vote Rating
    4
    Jan (HL) is on a distinguished road

      1  

    Default


    Quote Originally Posted by Animal View Post
    All those pages seem quite opaque in what actually happens.

    Can you post some possible example of what you would like to happen?
    PHP Code:
    // Proposal
    var gridStoredetailsStoretreegridform;
    tree.on('click', function(treerecord){
      var 
    promise gridStore.load({id record.get('id')});
      
    promise.success(detailsStore.load).success(form.update).failure(form.showError);
    });

    // instead of something like this.
    tree.on('click', function(treerecord){
      
    gridStore.load({
        
    id record.get('id'), 
        
    callback : function(rosuccess){
          if (
    success) {
            
    detailsStore.load({
              
    callback:function(rosuccess){
                if (
    success) {
                  
    form.update(record);
                } else {
                  
    form.showError();
                }
              }
            });
          } else {
            
    form.showError();
          }
        }
      });
    }); 
    It's not just callbacks. It is a different way of dispatching events. The real problem I see is the challenge of Sencha to provide an api which *is* deferable. Without chaining support (like jQuery) it is useless.

    Again, an example of jQuery promise implementation:
    PHP Code:
    var ajaxPromise = $.ajax('myurl').done(function(response){
      
    console.info("the response: " response);
    }).
    fail(function(){
      
    console.warn(arguments);
    });
    // oops, I need additional callbacks?
    ajaxPromise.done(function(){
      
    console.info('done!!');
    }).
    always(function(){
      
    console.log("whatever happend, I'm here");
    }); 

  2. #12
    Sencha User
    Join Date
    Sep 2010
    Posts
    4
    Vote Rating
    1
    jefftrull is on a distinguished road

      0  

    Default jQuery has this

    jQuery has this


    One of the main uses for this feature is to save coders from callback spaghetti hell. Instead of deeply nested success/failure callback code you describe a series of operations as objects and then compose them. The jQuery implementation is pretty nice and is covered in detail here: http://net.tutsplus.com/tutorials/javascript-ajax/wrangle-async-tasks-with-jquery-promises/

    E
    xtJS is nearly always ahead of the curve in terms of good design practices, so I'm surprised not to see something like this in there yet.

  3. #13
    Sencha User
    Join Date
    Sep 2011
    Posts
    1
    Vote Rating
    0
    StevenW is an unknown quantity at this point

      0  

    Default


    the fact that sencha is completely clueless about promises/futures and think they're just callbacks is absolutely disconcerting to me.

  4. #14
    Sencha User
    Join Date
    Jun 2012
    Location
    Auckland, New Zealand
    Posts
    6
    Vote Rating
    1
    walter.rumsby is on a distinguished road

      1  

    Default


    It's worth noting that jQuery's implementation isn't a 100% faithful implementation of Promises - see You're Missing the Point of Promises for more.

  5. #15
    Sencha User
    Join Date
    May 2011
    Location
    Melbourne, Australia
    Posts
    37
    Vote Rating
    1
    Greg Arnott is on a distinguished road

      0  

    Default


    I know this is a little late, but for reference.
    A great article by Matt Goldspink "Promises in Ext.js and Sencha Touch":
    http://www.mattgoldspink.co.uk/2013/...-sencha-touch/