raid-ox / xi
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
app/ | Thu Apr 30 06:04:20 -0700 2009 | |
| |
index.html | Thu Apr 30 06:04:08 -0700 2009 | |
| |
lib/ | Thu Apr 30 06:10:06 -0700 2009 | |
| |
readme.textile | Thu Apr 30 06:04:20 -0700 2009 | |
| |
xi/ | Thu Apr 30 06:04:08 -0700 2009 |
Xi Framework
Currently it is reduced to a loader with a packaging tool. Though it has a stacktracer to make
debugging easier.
Usage
Creating a Library
The library convention of Xi is similar to java. if your library has a namespace like:
com.domain.package you will have to create a file package.js inside lib/com/domain/
Note: namespace xi. and app. are reserved.
Edit the file and code:
xi.provide(‘com.domain.package’, function(xi){
xi.require(‘xi.io’); // Require some lib to be loaded
xi.using(‘xi.lang.*’) // import all classes of xi.lang to current xi object
xi.using(‘xi.lang.Array’) // import only Array
var array = xi.Array.uniq([1,2,2,1,3]); // Array is imported from xi.lang
// Private Class
var PrivateClass = function () {};
// Private Variable
var someVar = “someVar”;
// Public Class
xi.PublicClass = function () {};
// Public Var
xi.publicVar = “yes”;
});
Separating Classes from package
If you want to separate Class files from package file just create a folder with the name of your package:
lib/com/domain/package/. Then create a file with your ClassName as the name, e.g.: PublicClass.js
Edit the file and put:
xi.provide(‘com.domain.package.PublicClass’, function(xi){
// Dont do this:
// xi.require(‘com.domain.package’); // it will cause depedency hell
// define only ONE public Class
xi.PublicClass = function(){};
});
Then in the package file:
xi.provide(‘com.domain.package’, function(xi){
xi.require(‘com.domain.package.PublicClass’);
});
Creating an Application
Open app/main.js and start writing your app :)
Custom path
Define path like this:
xi.path({
‘xi.lang’: ‘compiled/core.js’,
‘xi.lang.Array’: ‘compiled/core.js’,
‘xi.lang.String’: ‘compiled/core.js’,
‘xi.lang.Class’: ‘compiled/core.js’,
‘xi.lang.Object’: ‘compiled/core.js’
});
