Using Sencha Ext.define versus Requirements

Ext.define('...', { uses: ['...'], }); 

and

 Ext.define('...', { requires: ['...'], }); 

I'm a little confused ... Do they have a common point of view? When do we use one or the other?

+7
source share
2 answers

To a large extent this applies to documentation:

Optional class dependencies are used, which are used, but not required by the class. They can be loaded asynchronously and should not be accessible to an instance of the class.

For example, if this is something that your class creates Foo in the constructor, then it should be in requires .

If he runs Foo in some method, which can later be called by the developer, he can go into uses .

+12
source

'requires' are needed to create a class, 'uses' are needed to create an object of this class.

Sequence of events:

  • Ext.define is called
  • 'require' and 'uses' are queued for loading asynchronously
  • a class is created when all its "requirements" are loaded.
  • Calls Ext.onReady is called when all classes are loaded, 'requires' and 'uses'
+5
source

All Articles