Giant Examples

Creating a new classA in Giant within global namespace like projectName. will be like

 
// creating new global namespace
    $projectName = {}; 
// creating new class named ClassA
    $oop.postpone($projectName,'ClassA', function(ns, classname){
    	var base = $oop.Base,
          	self = base.extend();

      	$projectName.ClassA = self.addMethods({
       	    init: function(){
            	console.log("I am classs A");
       	    }
      	});
    });

// create a new object of classA
var objA = $projectName.ClassA.create(); // giant will internally call the init method on creating a new object of a class.

Creating a new classB and extending it by classA

    $oop.postpone($projectName, 'ClassB', function(ns, classname) {
        var base = $projectName.ClassA,
            self = base.extend();
        $projectName.ClassB = self.addMethods({
            init: function() {
                base.init.call(this);
                console.log("I am classs B");
            }
        })
    });
    $projectName.ClassB.create();

Now suppose we are creating a project and want some utility classes for project we can use giant OOP class to create some classes like.

// First we create a new namespace for utils clsses 
$utils = {};

//Now we will create a class StringUtils class for modify strings
    $oop.postpone($utils, "StringUtils", function(ns, classname){
        var base = $oop.Base,
            self = base.extend();

        $utils.StringUtils = self.addMethods({
            splitString: function(str){
                $assertion.isString(str, "Invalid String value provided");
                return str.split(" ");
            },
            trimString: function(str){
                $assertion.isString(str, "Invalid String value provided");
                return str.trim();
            }
        })
    });

    $utils.StringUtils.splitString("a b c"); // [a,b,c]
    $utils.StringUtils.splitString(123); // throws exception for wrong string value provided
    $utils.StringUtils.trimString(' abc '); // "abc"

Giant OOP

Giant OOP is a namespace which gives us functionality to implement oops feature using giant in our application. Following are the different component of Giant OOP

Feature:-  it is a class which implements methods to detect environment features relevant to OOP and testing. Below are the basic function that feature provide us.

  • canAssignToReadOnly Determines whether read-only properties may be covered up by assignment.
  • hasPropertyAttributes Determines whether ES5 property attributes are available.

writable:-  A flag to determine if methods are writable or not.

testing:-  A flag to determine if application is in testing mode.

Read more

Giant Assertion

Giant assertion is a namespace which gives us functionality to implement validation via giant. There are different function available by which we can add our own custom validator. the default available functions are

assert:- Asserts an expression. check if expression is valid otherwise throws assertion error.

addType:- For adding up new validator.

addTypes:- For adding multiple validator at one go.

customHandler:- For global handler

 

 

Giant Intoduction

GiantJS is a full featured Javascript framework for creating single page application. it follows OOPS with modular development of web applications. By using giant we ensures that each part of the application is divided into small parts.  Below are the main components of giantJS

Giant Assertion:-  Giant Asserting namespace are used for validation on defferent places all over the development cicle. click here

Giant OOP:-   Giant OOP is the base namespace.  Ideally all classes must be extended either by oops or its extend classes to follow the oops rules. click here For available methods on Giant OOP.

Other Namesspaces we can create as per our need like

Giant Utils:-  Giant Utils is a class which contains all general purpose utility functions like stringifier(to stringify an objects)

Giant Data:-  Giant Data is a class which gives us functionality to create different type of data collections like ArrayCollection, Collection, DataCollection, Hash etc..

Giant Events:-  Giant Events is a class for handling event related functionality like catching and firing events adding multiple data with events.

Giant Routing:-  Giant Routing is a class which gives us functionality of handling Routing related functionality on the fly. it is responsible for triggering on any page changes and load new page according to the routes.

Giant Widget:- Giant Widget is a class which gives us functionality to create different widget(UI) for the application. suppose our page as a UI first our page will be a widget then it must have three child first one will be the header widget, second one will be the body widget, then footer will be the last widget. Then our header widget will be divided into several widgets like logo widget, menu widget, search bar widget etc….

 

Example of giant code can be found here