Skip to content

Commit

Permalink
Merge branch 'restructuring' of github.com:logsol/chuck.js into restr…
Browse files Browse the repository at this point in the history
…ucturing
  • Loading branch information
Jeena Paradies committed Jul 22, 2012
2 parents 4e3f207 + 6f28a10 commit b8e6a96
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
41 changes: 19 additions & 22 deletions app/Game/Server/NotificationCenter.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,52 +1,49 @@
define(function() {
define(

function NotificationCenter() {
this.topics = {};
this.subUid = -1;
}
var NotificationCenter = {
topics: {},
subUid: -1
};

NotificationCenter.prototype.trigger = function(topic, args) {
if (!this.topics[topic]) {
NotificationCenter.trigger = function(topic, args) {
if (!NotificationCenter.topics[topic]) {
throw "No such topic " + topic + ". Could not trigger.";
}

var subscribers = this.topics[topic];
var subscribers = NotificationCenter.topics[topic];
var len = subscribers ? subscribers.length : 0;

while (len--) {
subscribers[len].func(topic, args);
}

return this;
}

NotificationCenter.prototype.on = function(topic, func) {
if (!this.topics[topic]) {
this.topics[topic] = [];
NotificationCenter.on = function(topic, func) {
if (!NotificationCenter.topics[topic]) {
NotificationCenter.topics[topic] = [];
}

var token = ( ++this.subUid ).toString();
this.topics[topic].push({
var token = ( ++NotificationCenter.subUid ).toString();
NotificationCenter.topics[topic].push({
token: token,
func: func
});

return token;
}

NotificationCenter.prototype.off = function(token) {
NotificationCenter.off = function(token) {

for(var m in this.topics) {
if (this.topics[m]) {
for(var i = 0, j = this.topics[m].length; i < j; i++) {
if (this.topics[m][i].token === token) {
this.topics[m].splice(i, 1);
for(var m in NotificationCenter.topics) {
if (NotificationCenter.topics[m]) {
for(var i = 0, j = NotificationCenter.topics[m].length; i < j; i++) {
if (NotificationCenter.topics[m][i].token === token) {
NotificationCenter.topics[m].splice(i, 1);
return token;
}
}
}
}
return this;
}

return NotificationCenter;
Expand Down
6 changes: 5 additions & 1 deletion app/Lib/Utilities/RequestAnimFrame.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
define(['Chuck/Settings'], function(Settings) {
define([
'Game/Config/Settings'
],

function(Settings) {

var requestAnimFrame = (function(){

Expand Down

0 comments on commit b8e6a96

Please sign in to comment.