raid-ox / xi

Javascript Framework

This URL has Read+Write access

xi /
name age message
directory app/ Thu Apr 30 06:04:20 -0700 2009 update [raid-ox]
file index.html Thu Apr 30 06:04:08 -0700 2009 update [raid-ox]
directory lib/ Thu Apr 30 06:10:06 -0700 2009 update [raid-ox]
file readme.textile Thu Apr 30 06:04:20 -0700 2009 update [raid-ox]
directory xi/ Thu Apr 30 06:04:08 -0700 2009 update [raid-ox]
readme.textile

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’
});