Results 1 to 2 of 2

Thread: Would I be able to get a critique on this code?

  1. #1
    Sencha User Trozdol's Avatar
    Join Date
    Jan 2009
    Location
    Nashville
    Posts
    64
    Answers
    2

    Default Would I be able to get a critique on this code?

    Hey guys! I was hoping I could get some feed back on the structure of my code below.

    I wanted to know from a structure standpoint what is good and bad. Should move some things around or is it good the way that it is?

    I also stripped out the code specific to this app and keep it general so theoretically it could be used in any app.

    This is such a common, but important feature so I wanted to make sure I wasn't missing some important thing.

    If anyone wants to tear it apart and let me know what I could do to write better code that would be amazing.

    Thanks!

    PHP Code:
    Ext.define('MyApp.controller.UserAccount', {
        
    extend'Ext.app.Controller',
        
        
    config: {
            
            
    control: {
                
                
    'login #loginBtn': {
                    
    tap 'login'
                
    },
                
                
    'login #registerBtn': {
                    
    tap 'register'
                
    },
                
                
    'login #forgotBtn': {
                    
    tap 'forgot'
                
    }
            }
        },
        
        
    init: {...},
        
        
    launch: {...},
        
        
    login: function (me) {
        
            var 
    form me.up('form');
            var 
    values form.getValues();
            var 
    route '/login';
            
            
    Ext.Viewport.Mask();
            
            
    this.submitToServer(valuesroute);
        },
        
        
    register: function (me) {
        
            var 
    form me.up('form');
            var 
    values form.getValues();
            var 
    route '/register';
            
            
    Ext.Viewport.Mask();
            
            
    this.submitToServer(valuesroute);
        },
        
        
    forgot: function (me) {
        
            var 
    form me.up('form');
            var 
    values form.getValues();
            var 
    route '/forgot';
            
            
    Ext.Viewport.Mask();
            
            
    this.submitToServer(valuesroute);
        },
        
        
    submitToServer: function (valuesroute) {

            var 
    onSuccess = function (response) {...};
        
            var 
    onFailure = function (response) {...};
        
            var 
    onCallback = function () {...};
            
            
    Ext.data.JsonP.request({
                
    urlapp_global.server route,
                
    timeout10000,
                
    callbackKey'callback',
                
    paramsvalues,
                
    scopethis,
                
    successonSuccess,
                
    failureonFailure,
                
    callbackonCallback
            
    });
        }
    }); 
    Shayne Trosdahl
    @Trozdol
    CodePen

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,448
    Answers
    3997

    Default

    What I like to do is fire custom events on the component itself. You make the login form a widget and you fire custom events from it. Then your controller can be generic enough to not be tied to your login view. So the listening of the button taps can be done within the login form and you would then just fire an event on the login view. Your controller would then listen to those events on the login form instead of the login form's buttons.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

Similar Threads

  1. Critique request: Jasmine testing Ext JS outside of browser
    By nenadg in forum Community Discussion
    Replies: 5
    Last Post: 9 Jul 2015, 5:16 AM
  2. Replies: 0
    Last Post: 1 Jul 2015, 11:39 AM
  3. Replies: 0
    Last Post: 1 Jul 2015, 11:39 AM
  4. Replies: 5
    Last Post: 21 Dec 2012, 6:27 AM
  5. Replies: 5
    Last Post: 29 Oct 2008, 2:24 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •