Defining a namespace with ExtJs5

Guid

I'm using ExtJs 5 and SenchaCmd.

In a package, I defined several classes in several files like this:

// Bar1.js
Ext.define('Foo.Bar1', {
   ...
});

// Bar2.js
Ext.define('Foo.Bar2', {
   ...
});

Now I'd like to just "augment" the Foo namespace with some general tools like this :

Ext.ns('Foo');
Foo.tool1 = function() { ... }
Foo.tool2 = function() { .... }
Foo.generalProp1 = 42;
(...)

What would be the better place and practive to declare this so that the Sencha Compiler embeds this file too?

Is it possible to "require" (in a way) a namespace like we require a class?

Krzysztof

You can use statics from new Ext:

Ext.define('Foo', {
    // declare static members
    statics: {
        method: function(){ return "static method"; }
    }
});

// Define class under Foo namespace
Ext.define('Foo.OtherClass', {
    method: function(){ return "instance method"; }
});

// Create instance of Foo.OtherClass
var o = Ext.create('Foo.OtherClass');

// Use static member
console.log(Foo.method());

// Use instance member
console.log(o.method());

Then you can treat your Foo namespace like class, and place as any other class. Then obviously you can also require that namespace, because it is also class.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Defining a namespace with ExtJs5

From Dev

ExtJS5 Namespace Confusion

From Dev

Defining a variable member of a namespace outside the scope of the namespace

From Dev

Defining a variable member of a namespace outside the scope of the namespace

From Dev

Validity of style of defining class in namespace

From Dev

Validity of style of defining class in namespace

From Dev

ExtJS5 CellClick events

From Dev

EXTJS5 Binding Radiogroup

From Dev

Extjs5 Textarea Resizing

From Dev

defining a constant to be used in different namespace php 5.4

From Dev

Defining template class member functions in a namespace?

From Dev

How to redraw or repaint surface in ExtJS5?

From Dev

How does defining and immediately calling an anonymous function solve namespace problems?

From Dev

Accessing sub-namespaces of a XAML namespace without defining a new xmlns

From Dev

ExtJs4 to ExtJs5 Upgrade: GroupedColumn Chart is not working

From Dev

ExtJS4.2 carousel not working with ExtJS5

From Dev

ExtJs5: How to read server response in Model.save

From Dev

ExtJS5 ViewModel using global declared store

From Dev

ExtJS5: TreePanel select event firing twice

From Dev

Custom drag'n'drop from a tree to a grid with Extjs5

From Dev

ExtJS5: Get rid of root property in proxy

From Dev

ExtJs5 - launch function not executed in Ext.application

From Dev

EXTJS5 MVVM: Get global controller from view controller

From Dev

Extjs5: How to query a component by various properties

From Dev

Adding additional attributes to ExtJS5 Grid Panel

From Dev

ExtJS5: Get rid of root property in proxy

From Dev

How to properly declare links in extjs5 viewmodel?

From Dev

Custom drag'n'drop from a tree to a grid with Extjs5

From Dev

How to change the label of bar chart in Extjs5?

Related Related

  1. 1

    Defining a namespace with ExtJs5

  2. 2

    ExtJS5 Namespace Confusion

  3. 3

    Defining a variable member of a namespace outside the scope of the namespace

  4. 4

    Defining a variable member of a namespace outside the scope of the namespace

  5. 5

    Validity of style of defining class in namespace

  6. 6

    Validity of style of defining class in namespace

  7. 7

    ExtJS5 CellClick events

  8. 8

    EXTJS5 Binding Radiogroup

  9. 9

    Extjs5 Textarea Resizing

  10. 10

    defining a constant to be used in different namespace php 5.4

  11. 11

    Defining template class member functions in a namespace?

  12. 12

    How to redraw or repaint surface in ExtJS5?

  13. 13

    How does defining and immediately calling an anonymous function solve namespace problems?

  14. 14

    Accessing sub-namespaces of a XAML namespace without defining a new xmlns

  15. 15

    ExtJs4 to ExtJs5 Upgrade: GroupedColumn Chart is not working

  16. 16

    ExtJS4.2 carousel not working with ExtJS5

  17. 17

    ExtJs5: How to read server response in Model.save

  18. 18

    ExtJS5 ViewModel using global declared store

  19. 19

    ExtJS5: TreePanel select event firing twice

  20. 20

    Custom drag'n'drop from a tree to a grid with Extjs5

  21. 21

    ExtJS5: Get rid of root property in proxy

  22. 22

    ExtJs5 - launch function not executed in Ext.application

  23. 23

    EXTJS5 MVVM: Get global controller from view controller

  24. 24

    Extjs5: How to query a component by various properties

  25. 25

    Adding additional attributes to ExtJS5 Grid Panel

  26. 26

    ExtJS5: Get rid of root property in proxy

  27. 27

    How to properly declare links in extjs5 viewmodel?

  28. 28

    Custom drag'n'drop from a tree to a grid with Extjs5

  29. 29

    How to change the label of bar chart in Extjs5?

HotTag

Archive