On 04/10/2012 03:44 PM, totty wrote:
> - I'm using "require" to get classes available to the program, but are
Is this the Node.js' built-in 'require'?!
> relative from where I need them so I have to take care that it's the right
> way to require them every time. I have to repeat things: once in the require
> and the other when I use the code;
What do you mean? Can you give an example of these two uses?
> I'm asking if it's possible to make some
> absolute require? require('/myapp/abc') instead of require('./abc') if I'm
In Node.js' 'require' you can always be passed an absolute path.
> in requiring it from the myapp folder or require('./myapp/abc') if I'm
> requiring it from the root folder.
Another alternative would be to use a 'node_modules' folder. If it is
e.g. a subfolder of your root folder, it would always be
require('myapp/abc'), no matter which of the enclosed files are
require'ing it. You can also achieve a similar effect using the
NODE_PATH os environment variable.
> I can provide an alternative idea:
> instead of using "things" like this:
> var a = new qx.core.Aspect();
> use:
> // in the beginning of the program
> qx.Class.define("myapp.class", [
> // uses
> 'qx.core.Aspect'
> ], function(u){
> //here we put extend, construct, properties and members
> this.members = {
> myMethod: function(){
> var a = new u.Aspect();
> // or
> var b = new u.qx.core.Aspect();
> // or
> var c = new u['qx.core.Aspect']();
> // or you could define an alias for that in the "uses" section
> // instead of ['qx.core.Aspect'] write [['qx.core.Aspect',
> 'myAlias']]
> var d = new u.myAlias();
> }
> }
> }
>
> the qooxdoo class should abstract the "require" part from the end user by
> using a closure that it's run only when files are loaded. I can provide a
> more "real" example of what I mean if interested.
Which problem are you trying to solve here? You're not aiming at getting
rid of code like
var a = new qx.core.Aspect()
, do you? As this would be breaking a lot of qooxdoo code.
You probably want to get rid of the corrsponding 'require' call
(something like 'require("qx/core/Aspect.js")')?! That's very sensible,
but you wouldn't need an entirely new qx.Class.define, would you?! And
you wouldn't want to declare all your dependencies, too. That's what the
generator is for. So a good solution for me would be that the generator
extracts all dependencies, generates the corresponding 'require' calls,
and wraps this code in front of your class definition.
This would be on a per-file basis. The generator is already doing
something similar, but on a file-set basis, in the current loader. So if
you e.g. use the 'basic' skeleton, the generator will create a loader
that handles all 'require's for you.
T.
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel