Class zebkit.Package | <zebkit> |
Package is a special class to declare zebkit packages. Global variable "zebkit" is root package for all other packages. To declare a new package use "zebkit" global variable:
// declare new "mypkg" package
zebkit.package("mypkg", function(pkg, Class) {
// put the package entities in
pkg.packageVariable = 10;
...
});
...
// now we can access package and its entities directly
zebkit.mypkg.packageVariable
// or it is preferable to wrap a package access with "require"
// method
zebkit.require("mypkg", function(mypkg) {
mypkg.packageVariable
});
zebkit.Package
(
)
private
|
void | $detectLocation ( ) |
public | <zebkit.Package> | byName (name) |
public | <String> | cd (path) |
public | void | config ([name], [value], [overwrite]) |
public | void | configWith (path, [cb]) |
public | void | configWithRs (path, [cb]) |
public | <String> | fullname ( ) |
public | <zebkit.Package> | getRootPackage ( ) |
public | <String> | import ([pkgname]) |
public | void | ls (cb, [all]) |
public | <zebkit.Package> | package (name, [callback], [config]) |
public | void | packages (callback, [recursively]) |
public | void | require ([packages], [callback]) |
public | void | resources (paths, cb) |
private
|
void | then (f) |
private
void
$detectLocation ( )
Detect the package location and store the location into "$url" package field |
public
<zebkit.Package>
byName (name )
Get a package by the specified name. Parameters:
Returns:
<zebkit.Package>
a package |
public
<String>
cd (path )
Find a package with the given file like path relatively to the given package. Parameters:
Returns:
<String>
path a path Example:
|
public
<zebkit.Package>
getRootPackage ( )
Detect root package.
Returns:
<zebkit.Package>
a root package |
public
<String>
import ([pkgname] )
Build import JS code string that can be evaluated in a local space to make visible the given package or packages classes, variables and methods. Parameters:
Returns:
<String>
an import string to be evaluated in a local JS space Example:
|
public
void
ls (cb, [all] )
List classes, variables and interfaces defined in the given package. If second parameter "all" passed to the method is false, the method will skip package entities whose name starts from "$" or "_" character. These entities are considered as private ones. Pay attention sub-packages are not listed. Parameters: |
public
<zebkit.Package>
package (name, [callback], [config] )
Method that has to be used to declare packages. Parameters:
Returns:
<zebkit.Package>
a package Example:
|
public
void
require ([packages], [callback] )
This method has to be used to start building a zebkit application. It expects a callback function where an application code has to be placed and number of required for the application packages names. The call back gets the packages instances as its arguments. The method guarantees the callback is called at the time zebkit and requested packages are loaded, initialized and ready to be used. Parameters:
Example:
|
public
void
resources (paths, cb )
This method loads resources (images, textual files, etc) and call callback method with completely loaded resources as input arguments. Parameters:
Example:
|
private
chainable
then (f )
This method helps to sync accessing to package entities with the package internal state. For instance package declaration can initiate loading resources that happens asynchronously. In this case to make sure the package completed loading its configuration we should use package "then" method. Parameters:
Example:
|