user203687
user203687

Reputation: 7237

What does Ext.Callback do in this case?

Trying to learn Sencha...

I came across the following code in a controller:

onViewMoreEventTap: function() {
    var me = this;
    Ext.callback(function(){
        me.getView().fireEvent('onViewMoreEventTap');
    }, me, [], 1);
}

What is the significance of passing an anonymous function to Ext.callback?

What does the snippet do in overall?

Upvotes: 0

Views: 2088

Answers (1)

Saki
Saki

Reputation: 5856

There are a couple of purposes for Ext.callback:

  1. to execute the function in a different scope
  2. to execute the function with different arguments
  3. to execute the function after a delay
  4. to execute a method of a different defaultListenerScope (Ext 5)

In this case it is because the author want to execute the inline function 1ms later (purpose 3). In JavaScript, executing some code 1ms later is a kind of multitasking that is not natively supported.

Upvotes: 1

Related Questions