1. #11
    Ext Premium Member Jan (HL)'s Avatar
    Join Date
    Aug 2010
    Location
    Germany
    Posts
    111
    Vote Rating
    9
    Jan (HL) will become famous soon enough

      2  

    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");
    }); 
    Mod: Sencha frameworks have chaining support, just override the methods you want chainable.

  2. #12
    Sencha User
    Join Date
    Sep 2010
    Posts
    5
    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
    3
    StevenW is on a distinguished road

      3  

    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 Premium Member
    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
    89
    Vote Rating
    7
    Greg Arnott is on a distinguished road

      1  

    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/

  6. #16
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Berne, Switzerland
    Posts
    714
    Vote Rating
    42
    ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about

      0  

    Default


    It looks like there is an implementation of Promises in ST2.3.1.
    You can find it in touch\src\promise.js

  7. #17
    Sencha User
    Join Date
    Nov 2011
    Posts
    21
    Vote Rating
    5
    Navaar is on a distinguished road

      0  

    Default


    DeftJS is quite nice for this. Also their ViewController implementation is quite nice. Their promises make things quite a bit less nested when dealing with asnychronous code.

    www.deftjs.org

  8. #18
    Sencha User Misiu's Avatar
    Join Date
    Jun 2012
    Location
    Poland
    Posts
    227
    Vote Rating
    40
    Misiu has a spectacular aura about Misiu has a spectacular aura about

      0  

    Default


    Quote Originally Posted by Greg Arnott View Post
    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/
    Nice article
    Why Sencha can't adopt solution that already is out there: rvsp.js, when.js, deft.js or many others.
    Deft is already ExtJS specific, so plugging this into core won't be so hard.

    I'm a beginner, but I think that both beginners like me and advanced users will take advantage of this feature.