Skip to content

Instantly share code, notes, and snippets.

View toddpi314's full-sized avatar
💻
Movies, Music & Microcode

Todd Morrison toddpi314

💻
Movies, Music & Microcode
View GitHub Profile
@toddpi314
toddpi314 / Rich_Domain_Components_UnloadTest.js
Created June 8, 2012 15:40
Rich_Domain_Components_UnloadTest
test("Component Unload Tests", function() {
var componentTestCount = 10;
var components = []
for (var i = 0; i <= componentTestCount - 1; i++) {
components.push(new DeepElement.ThreeOneFour.Component());
}
var comonentLoader = new DeepElement.ThreeOneFour.Helpers.ComponentLoader(
components);
@toddpi314
toddpi314 / Rich_Domain_Components_Example.js
Created June 8, 2012 15:34
Rich_Domain_Components_Example
// Build the loader instance and pass in your ordered list of Concrete types that implement DeepElement.ThreeOneFour.Component
var comonentLoader = new DeepElement.ThreeOneFour.Helpers.ComponentLoader(
components);
comonentLoader.load(function() {
// all components have loaded
}, function() {
// a component failed
// check the "this" context to find out which one
});​
@toddpi314
toddpi314 / Rich_Domain_Components_LoadTest.js
Created June 8, 2012 15:31
Rich_Domain_Components_LoadTest
test("Component Load Tests", function() {
var componentTestCount = 10;
var components = []
for (var i = 0; i <= componentTestCount - 1; i++) {
components.push(new DeepElement.ThreeOneFour.Component());
}
var comonentLoader = new DeepElement.ThreeOneFour.Helpers.ComponentLoader(
components);
@toddpi314
toddpi314 / Rich_Domain_Components_Loader.js
Created June 8, 2012 15:23
Rich_Domain_Components_Loader
Namespace.Register('DeepElement.ThreeOneFour.Helpers.ComponentLoader');
/*
* Asynchronous Loader for Components
*/
DeepElement.ThreeOneFour.Helpers.ComponentLoader = new Class({
instances: null,
initialize: function(instances) {
this.instances = instances;
},
@toddpi314
toddpi314 / Rich_Domain_Components_2.js
Created June 8, 2012 15:18
Rich_Domain_Components_2
var component1 = new DeepElement.ThreeOneFour.Component();
var component2 = new DeepElement.ThreeOneFour.Component();
var component3 = new DeepElement.ThreeOneFour.Component();
component1.load(function() {
component2.load(function() {
component3.load(function() {
// phewww! all three loadedF
}, function() {
// component3 failed to load
@toddpi314
toddpi314 / Rich_Domain_Concepts.js
Created June 8, 2012 15:13
Rich_Domain_Concepts
Namespace.Register("DeepElement.ThreeOneFour.Component")
/*
* Represents a Javascript Component Baseclass that supports async
* loading/unloading
*
*/
DeepElement.ThreeOneFour.Component = new Class({
Implements: Events,
@toddpi314
toddpi314 / GameClock_ThreeOneFour_Usage.js
Created June 7, 2012 22:20
GameClock_ThreeOneFour_Usage
for (var i = 0; i <= 100; i++) {
var clock = new DeepElement.ThreeOneFour.Clock();
var self = this;
clock.addEvent('tick', function(td) {
console.log('tick');
var doSomethingWithSelf = self;
});
clock.start();
clock.stop();
delete clock;
@toddpi314
toddpi314 / GameClock_ThreeOneFour_Impl1.js
Created June 7, 2012 22:14
GameClock_ThreeOneFour_Impl1
DeepElement.ThreeOneFour.Common.Clock = new Class({
Implements: Events,
running: false,
interval: null,
t0: +new Date(),
rAFSupport: false,
initialize: function() {
self.requestAnimFrame = (function() {
return self.requestAnimationFrame || self.webkitRequestAnimationFrame || self.mozRequestAnimationFrame || self.oRequestAnimationFrame || self.msRequestAnimationFrame;
})();
@toddpi314
toddpi314 / GameClock_ShimLayer_1.js
Created June 7, 2012 22:03
GameClock_ShimLayer_1
self.requestAnimFrame = (function() {
return self.requestAnimationFrame || self.webkitRequestAnimationFrame || self.mozRequestAnimationFrame || self.oRequestAnimationFrame || self.msRequestAnimationFrame ||
function(callback) {
self.setTimeout(callback, 1000 / 60);
};
})();​
@toddpi314
toddpi314 / Javascript_NamespaceCreation_Sample.js
Created June 7, 2012 01:16
Javascript_NamespaceCreation_Sample
Namespace.Register('MyApp.Loader');
Namespace.Register('MyApp.ORM.Mappers');
MyApp.Loader.appLoader = function() {
// Load application
};
MyApp.Loader.modelLoader = function() {
// Load up my Models
};​