Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Commit v.1.3.1

Improve aListeningEvents generation. Now the listening events are taken from oEventsCallbacks property of methods. - Thanks, Ramonacus -
  • Loading branch information...
commit 59f15e684603428ce60104a8e24e02b86e1d46d0 1 parent f8bded2
@tcorral authored
View
4 README.md
@@ -1,8 +1,10 @@
# Hydra.js
Hidra.js is a module manager oriented system.
-## Updated to version 1.3.0
+## Updated to version 1.3.1
+#### ChangeLog 1.3.1 :
+ Improve aListeningEvents generation. Now the listening events are taken from oEventsCallbacks property of methods. - Thanks, Ramonacus -
#### ChangeLog 1.3.0 :
Delegate some repetitive jobs to the module instance creator, maintaining the size of Hydra.
View
16 examples_and_documents/js/Hydra.js
@@ -97,12 +97,24 @@
oModule = oModules[sModuleId].creator(oAction);
fpInitProxy = oModule.init;
oModule.__action__ = oAction;
+ oModule.oEventsCallbacks = oModule.oEventsCallbacks || {};
+ oModule.aListeningEvents = (function()
+ {
+ var oEventsCallbacks = oModule.oEventsCallbacks,
+ sKey,
+ aListeningEvents = [];
+ for (sKey in oEventsCallbacks) {
+ if (oEventsCallbacks.hasOwnProperty(sKey)) {
+ aListeningEvents.push(sKey);
+ }
+ }
+ oEventsCallbacks = sKey = null;
+ return aListeningEvents;
+ }());
oModule.init = function () {
oAction.listen(this.aListeningEvents, this.handleAction, this);
fpInitProxy.call(this, arguments);
};
- oModule.aListeningEvents = oModule.aListeningEvents || [];
- oModule.oEventsCallbacks = oModule.oEventsCallbacks || {};
oModule.handleAction = function (oNotifier) {
var fpCallback = this.oEventsCallbacks[oNotifier.type];
if (fpCallback === _undefined_) {
View
16 src/Hydra.js
@@ -97,12 +97,24 @@
oModule = oModules[sModuleId].creator(oAction);
fpInitProxy = oModule.init;
oModule.__action__ = oAction;
+ oModule.oEventsCallbacks = oModule.oEventsCallbacks || {};
+ oModule.aListeningEvents = (function()
+ {
+ var oEventsCallbacks = oModule.oEventsCallbacks,
+ sKey,
+ aListeningEvents = [];
+ for (sKey in oEventsCallbacks) {
+ if (oEventsCallbacks.hasOwnProperty(sKey)) {
+ aListeningEvents.push(sKey);
+ }
+ }
+ oEventsCallbacks = sKey = null;
+ return aListeningEvents;
+ }());
oModule.init = function () {
oAction.listen(this.aListeningEvents, this.handleAction, this);
fpInitProxy.call(this, arguments);
};
- oModule.aListeningEvents = oModule.aListeningEvents || [];
- oModule.oEventsCallbacks = oModule.oEventsCallbacks || {};
oModule.handleAction = function (oNotifier) {
var fpCallback = this.oEventsCallbacks[oNotifier.type];
if (fpCallback === _undefined_) {
View
16 versions/hydra.developer.js
@@ -97,12 +97,24 @@
oModule = oModules[sModuleId].creator(oAction);
fpInitProxy = oModule.init;
oModule.__action__ = oAction;
+ oModule.oEventsCallbacks = oModule.oEventsCallbacks || {};
+ oModule.aListeningEvents = (function()
+ {
+ var oEventsCallbacks = oModule.oEventsCallbacks,
+ sKey,
+ aListeningEvents = [];
+ for (sKey in oEventsCallbacks) {
+ if (oEventsCallbacks.hasOwnProperty(sKey)) {
+ aListeningEvents.push(sKey);
+ }
+ }
+ oEventsCallbacks = sKey = null;
+ return aListeningEvents;
+ }());
oModule.init = function () {
oAction.listen(this.aListeningEvents, this.handleAction, this);
fpInitProxy.call(this, arguments);
};
- oModule.aListeningEvents = oModule.aListeningEvents || [];
- oModule.oEventsCallbacks = oModule.oEventsCallbacks || {};
oModule.handleAction = function (oNotifier) {
var fpCallback = this.oEventsCallbacks[oNotifier.type];
if (fpCallback === _undefined_) {
View
BIN  versions/hydra.min.gz
Binary file not shown
View
2  versions/hydra.min.js
@@ -1 +1 @@
-(function(i,A,B,s){var o,j,d,n,v,h,g,q,w,z,C,f,x,e,b,r;if(B===s){B=i}n=null;v=false;h=true;o={};j=i.console;d=/resolve/g;g="1.3.0";w=v;x={};function c(D){return{}.toString.call(D)==="[object Function]"}function a(D){w=D}function t(E,D){return[].slice.call(E,D||0)}function u(D,E){return D.hasOwnProperty(E)}function l(E,G,F,D){E[G]=(function(I,H){return function(){var K=t(arguments,0);try{return H.apply(this,K)}catch(J){z.log(F,I,J)}finally{K=n}}}(G,D))}function m(E,G){var F,D;F=o[E].creator(G);D=F.init;F.__action__=G;F.init=function(){G.listen(this.aListeningEvents,this.handleAction,this);D.call(this,arguments)};F.aListeningEvents=F.aListeningEvents||[];F.oEventsCallbacks=F.oEventsCallbacks||{};F.handleAction=function(I){var H=this.oEventsCallbacks[I.type];if(H===s){return}H.call(this,I)};F.onDestroy=function(){};F.destroy=function(){this.onDestroy();G.stopListen(this.aListeningEvents,this)};return F}function p(F){var H,E,G,D;if(o[F]===s){throw new Error("The module is not registered!")}H=new f();G="";D=function(){};E=m(F,H);if(!w){for(G in E){if(u(E,G)){D=E[G];if(!c(D)){continue}l(E,G,F,D)}}}try{return E}finally{H=n;E=n;G=n;D=n}}z=function(){};z.type="ErrorHandler";z.list=n;z.create_dom=function(){var D,F,E;D=A.createElement("div");F=A.createElement("ul");E=D.style;this.list=F;E.display="none";E.position="fixed";E.height="100px";E.width="100%";E.bottom="0px";D.appendChild(F);A.body.appendChild(D);D=n;F=n;E=n};z.addItem=function(E,D,F){var G;G=A.createElement("li");G.appendChild(A.createTextNode(E+"/"+D+": "+F.message));this.list.appendChild(G);G=n};z.log=function(){var D;D=t(arguments,0).concat();if(j===s||(typeof D[D.length-1]==="boolean"&&!D[D.length-1])){if(this.list===n){this.create_dom()}this.addItem.apply(this,D);z.__old_log__=z.log;this.log=function(){var E=t(arguments,0).concat();this.addItem.apply(this,E);E=n}}else{j.log.apply(j,D);z.__old_log__=z.log;this.log=function(){var E=t(arguments,0).concat();j.log.apply(j,E);E=n}}D=n};C=function(){};C.prototype={type:"Module",register:function(E,D){o[E]={creator:D,instance:n};return o[E]},_merge:function(I,D,G){var E,H,F;E={};F=function(J){return function(){var K=t(arguments,0);J.apply(this,K)}};if(G){E.__super__={};E.__super__.__instance__=I;E.__super__.__call__=function(K,L){var J=this;while(u(J,K)===v){J=J.__instance__.__super__}J[K].apply(E,L)}}for(H in I){if(u(I,H)){if(H==="__super__"){continue}E[H]=I[H]}}for(H in D){if(u(D,H)){if(E.__super__!==s&&c(E[H])){E.__super__[H]=(F(E[H]));E[H]=D[H]}else{E[H]=D[H]}}}try{return E}finally{E=n;H=n}},extend:function(J,F,H){var E,I,M,G,K,D,L;E=o[J];I=J;M=function(N){return N};if(typeof F==="string"){I=F;M=H}else{M=F}if(E===s){return}L=new f();K=M(L);G=E.creator(L);D=this._merge(G,K,(I!==J));D.__action__=L;o[I]={creator:(function(N){return function(){return N}}(D)),instance:n};E=n;I=n;M=n;G=n;K=n;D=n;L=n},test:function(D,E){if(jstestdriver){a(h);E(p(D));a(v)}},getModule:function(E,D){var F=o[E];if(jstestdriver){F={};F.instance=p(E);return o[E]=F}return null},start:function(D,G,F){var E;E=o[D];if(F&&this.isModuleStarted(D)){this.stop(D)}if(E!==s){E.instance=p(D);E.instance.init(G)}E=n},isModuleStarted:function(D){return(typeof o[D]!==s&&o[D].instance!==n)},startAll:function(){var D;for(D in o){if(u(o,D)){this.start(D)}}D=n},stop:function(D){var E;E=o[D];if(E!==s&&E.instance!==n){E.instance.destroy();E.instance=n}},stopAll:function(){var D;for(D in o){if(u(o,D)){this.stop(D)}}D=n},_delete:function(D){delete o[D]},remove:function(D){var E;E=o[D];if(E!==s){try{return E}finally{o[D]=n;this._delete(D)}}}};f=function(){};f.prototype={type:"Action",listen:function(H,F,I){var E,D,G;E="";G=H.length;for(D=0;D<G;D=D+1){E=H[D];if(x[E]===s){x[E]=[]}x[E].push({module:I,handler:F})}},notify:function(F){var H,G,E,D;H=F.type;G=n;if(x[H]===s){return}D=x[H].length;for(E=0;E<D;E=E+1){G=x[H][E];G.handler.call(G.module,F)}H=n;E=n;D=n;G=n},stopListen:function(K,I){var E,H,D,G,J,F;E="";H=[];G=K.length;J=0;F=0;for(D=0;D<G;D=D+1){H=[];E=K[D];F=x[E].length;for(J=0;J<F;J=J+1){if(I!==x[E][J].module){H.push(x[E][J])}}x[E]=H;if(x[E].length===0){delete x[E]}}E=n;H=n;D=n;G=n;J=n;F=n},__restore__:function(){x={}}};e=function(){this.aPending=[];this.bCompleted=v;this.sType="";this.oResult=n;this.oAction=q.action();this.resolve=(function(D){return function(E){D.bCompleted=h;D.sType="resolve";D.oResult=E;D.oAction.notify({type:"complete"})}}(this));this.reject=(function(D){return function(E){D.bCompleted=h;D.sType="reject";D.oResult=E;D.oAction.notify({type:"complete"})}}(this))};e.prototype.then=function(D,E){this.aPending.push({resolve:D,reject:E});return this};b=function(){this.aPromises=[];this.aPending=[];this.sType="";this.oAction=q.action();this.oAction.listen(["complete"],this.checkCompleted,this)};b.prototype={add:function(D){this.aPromises.push(D);return this},checkCompleted:function(){var F,D,E;D=this.aPromises.length;E=n;for(F=0;F<D;F++){E=this.aPromises[F];if(!E.bCompleted){return v}}this.complete(this.getType());F=n;D=n;E=n},getType:function(){var G,E,F,D,H;E=this.aPromises.length;F=n;D=[];for(G=0;G<E;G++){F=this.aPromises[G];if(F.bCompleted){D.push(F.sType)}}if(D.length===0){return""}H=D.join("").replace(d,"").length>0?"reject":"resolve";try{return H}finally{G=n;E=n;F=n;D=n}},complete:function(G){var F,D,E;if(G.length===0){return v}D=this.aPromises.length;for(F=0;F<D;F++){E=this.aPromises[F];while(E.aPending[0]){E.aPending.shift()[G](E.oResult)}}while(this.aPending[0]){this.aPending.shift()[G]()}F=n;D=n;E=n},then:function(D,E){this.aPending.push({resolve:D,reject:E});return this}};r=function(){var H,F,G,D,E;H=t(arguments,0);G=H.length;E=n;this.oDeferred=D=new b();for(F=0;F<G;F++){E=H[F];if(E instanceof e){D.add(E)}else{D.complete("resolved");return}}try{return D}finally{H=n;F=n;G=n;E=n}};function k(){return z}function y(D){z=D}q=function(){};q.version=g;q.action=function(){return new f()};q.errorHandler=k;q.setErrorHandler=y;q.module=new C();q.setDebug=a;q.deferred=b;q.promise=e;q.when=r;B.Hydra=q}(window,document));
+(function(i,A,B,s){var o,j,d,n,v,h,g,q,w,z,C,f,x,e,b,r;if(B===s){B=i}n=null;v=false;h=true;o={};j=i.console;d=/resolve/g;g="1.3.0";w=v;x={};function c(D){return{}.toString.call(D)==="[object Function]"}function a(D){w=D}function t(E,D){return[].slice.call(E,D||0)}function u(D,E){return D.hasOwnProperty(E)}function l(E,G,F,D){E[G]=(function(I,H){return function(){var K=t(arguments,0);try{return H.apply(this,K)}catch(J){z.log(F,I,J)}finally{K=n}}}(G,D))}function m(E,G){var F,D;F=o[E].creator(G);D=F.init;F.__action__=G;F.oEventsCallbacks=F.oEventsCallbacks||{};F.aListeningEvents=(function(){var I=F.oEventsCallbacks,J,H=[];for(J in I){if(I.hasOwnProperty(J)){H.push(J)}}I=J=null;return H}());F.init=function(){G.listen(this.aListeningEvents,this.handleAction,this);D.call(this,arguments)};F.handleAction=function(I){var H=this.oEventsCallbacks[I.type];if(H===s){return}H.call(this,I)};F.onDestroy=function(){};F.destroy=function(){this.onDestroy();G.stopListen(this.aListeningEvents,this)};return F}function p(F){var H,E,G,D;if(o[F]===s){throw new Error("The module is not registered!")}H=new f();G="";D=function(){};E=m(F,H);if(!w){for(G in E){if(u(E,G)){D=E[G];if(!c(D)){continue}l(E,G,F,D)}}}try{return E}finally{H=n;E=n;G=n;D=n}}z=function(){};z.type="ErrorHandler";z.list=n;z.create_dom=function(){var D,F,E;D=A.createElement("div");F=A.createElement("ul");E=D.style;this.list=F;E.display="none";E.position="fixed";E.height="100px";E.width="100%";E.bottom="0px";D.appendChild(F);A.body.appendChild(D);D=n;F=n;E=n};z.addItem=function(E,D,F){var G;G=A.createElement("li");G.appendChild(A.createTextNode(E+"/"+D+": "+F.message));this.list.appendChild(G);G=n};z.log=function(){var D;D=t(arguments,0).concat();if(j===s||(typeof D[D.length-1]==="boolean"&&!D[D.length-1])){if(this.list===n){this.create_dom()}this.addItem.apply(this,D);z.__old_log__=z.log;this.log=function(){var E=t(arguments,0).concat();this.addItem.apply(this,E);E=n}}else{j.log.apply(j,D);z.__old_log__=z.log;this.log=function(){var E=t(arguments,0).concat();j.log.apply(j,E);E=n}}D=n};C=function(){};C.prototype={type:"Module",register:function(E,D){o[E]={creator:D,instance:n};return o[E]},_merge:function(I,D,G){var E,H,F;E={};F=function(J){return function(){var K=t(arguments,0);J.apply(this,K)}};if(G){E.__super__={};E.__super__.__instance__=I;E.__super__.__call__=function(K,L){var J=this;while(u(J,K)===v){J=J.__instance__.__super__}J[K].apply(E,L)}}for(H in I){if(u(I,H)){if(H==="__super__"){continue}E[H]=I[H]}}for(H in D){if(u(D,H)){if(E.__super__!==s&&c(E[H])){E.__super__[H]=(F(E[H]));E[H]=D[H]}else{E[H]=D[H]}}}try{return E}finally{E=n;H=n}},extend:function(J,F,H){var E,I,M,G,K,D,L;E=o[J];I=J;M=function(N){return N};if(typeof F==="string"){I=F;M=H}else{M=F}if(E===s){return}L=new f();K=M(L);G=E.creator(L);D=this._merge(G,K,(I!==J));D.__action__=L;o[I]={creator:(function(N){return function(){return N}}(D)),instance:n};E=n;I=n;M=n;G=n;K=n;D=n;L=n},test:function(D,E){if(jstestdriver){a(h);E(p(D));a(v)}},getModule:function(E,D){var F=o[E];if(jstestdriver){F={};F.instance=p(E);return o[E]=F}return null},start:function(D,G,F){var E;E=o[D];if(F&&this.isModuleStarted(D)){this.stop(D)}if(E!==s){E.instance=p(D);E.instance.init(G)}E=n},isModuleStarted:function(D){return(typeof o[D]!==s&&o[D].instance!==n)},startAll:function(){var D;for(D in o){if(u(o,D)){this.start(D)}}D=n},stop:function(D){var E;E=o[D];if(E!==s&&E.instance!==n){E.instance.destroy();E.instance=n}},stopAll:function(){var D;for(D in o){if(u(o,D)){this.stop(D)}}D=n},_delete:function(D){delete o[D]},remove:function(D){var E;E=o[D];if(E!==s){try{return E}finally{o[D]=n;this._delete(D)}}}};f=function(){};f.prototype={type:"Action",listen:function(H,F,I){var E,D,G;E="";G=H.length;for(D=0;D<G;D=D+1){E=H[D];if(x[E]===s){x[E]=[]}x[E].push({module:I,handler:F})}},notify:function(F){var H,G,E,D;H=F.type;G=n;if(x[H]===s){return}D=x[H].length;for(E=0;E<D;E=E+1){G=x[H][E];G.handler.call(G.module,F)}H=n;E=n;D=n;G=n},stopListen:function(K,I){var E,H,D,G,J,F;E="";H=[];G=K.length;J=0;F=0;for(D=0;D<G;D=D+1){H=[];E=K[D];F=x[E].length;for(J=0;J<F;J=J+1){if(I!==x[E][J].module){H.push(x[E][J])}}x[E]=H;if(x[E].length===0){delete x[E]}}E=n;H=n;D=n;G=n;J=n;F=n},__restore__:function(){x={}}};e=function(){this.aPending=[];this.bCompleted=v;this.sType="";this.oResult=n;this.oAction=q.action();this.resolve=(function(D){return function(E){D.bCompleted=h;D.sType="resolve";D.oResult=E;D.oAction.notify({type:"complete"})}}(this));this.reject=(function(D){return function(E){D.bCompleted=h;D.sType="reject";D.oResult=E;D.oAction.notify({type:"complete"})}}(this))};e.prototype.then=function(D,E){this.aPending.push({resolve:D,reject:E});return this};b=function(){this.aPromises=[];this.aPending=[];this.sType="";this.oAction=q.action();this.oAction.listen(["complete"],this.checkCompleted,this)};b.prototype={add:function(D){this.aPromises.push(D);return this},checkCompleted:function(){var F,D,E;D=this.aPromises.length;E=n;for(F=0;F<D;F++){E=this.aPromises[F];if(!E.bCompleted){return v}}this.complete(this.getType());F=n;D=n;E=n},getType:function(){var G,E,F,D,H;E=this.aPromises.length;F=n;D=[];for(G=0;G<E;G++){F=this.aPromises[G];if(F.bCompleted){D.push(F.sType)}}if(D.length===0){return""}H=D.join("").replace(d,"").length>0?"reject":"resolve";try{return H}finally{G=n;E=n;F=n;D=n}},complete:function(G){var F,D,E;if(G.length===0){return v}D=this.aPromises.length;for(F=0;F<D;F++){E=this.aPromises[F];while(E.aPending[0]){E.aPending.shift()[G](E.oResult)}}while(this.aPending[0]){this.aPending.shift()[G]()}F=n;D=n;E=n},then:function(D,E){this.aPending.push({resolve:D,reject:E});return this}};r=function(){var H,F,G,D,E;H=t(arguments,0);G=H.length;E=n;this.oDeferred=D=new b();for(F=0;F<G;F++){E=H[F];if(E instanceof e){D.add(E)}else{D.complete("resolved");return}}try{return D}finally{H=n;F=n;G=n;E=n}};function k(){return z}function y(D){z=D}q=function(){};q.version=g;q.action=function(){return new f()};q.errorHandler=k;q.setErrorHandler=y;q.module=new C();q.setDebug=a;q.deferred=b;q.promise=e;q.when=r;B.Hydra=q}(window,document));
Please sign in to comment.
Something went wrong with that request. Please try again.