Permalink
Browse files

refactoring due to dojo/on changes

  • Loading branch information...
1 parent c2a5cc0 commit 9ff7a5f9f83e07f157f90ee202408cee37bad230 @neonstalwart neonstalwart committed Sep 8, 2011
Showing with 17 additions and 16 deletions.
  1. +9 −8 message/Fiber.js
  2. +3 −3 model/Model.js
  3. +3 −3 model/Registry.js
  4. +2 −2 support/{on.js → Evented.js}
View
@@ -19,10 +19,12 @@ define([
'../support/lang',
'./ListenerProxy',
'./InterceptorProxy',
- '../support/on'
-], function (arr, compose, Router, lang, ListenerProxy, InterceptorProxy, on) {
+ '../support/Evented'
+], function (arr, compose, Router, lang, ListenerProxy, InterceptorProxy, Evented) {
'use strict';
+ var hub = new Evented();
+
function MessageFiber() {
this._listeners = [];
this.router = new Router();
@@ -80,12 +82,11 @@ define([
// functionName: 'topic/to/publish'
// }
arr.forEach(lang.keys(model.publish), function (prop) {
- var topic = 'on' + model.publish[prop];
+ var topic = model.publish[prop];
pubs[prop] = function () {
- var listeners = on[topic];
- if (listeners) {
- listeners.apply(this, arguments);
- }
+ var args = [topic];
+ args.push.apply(args, arguments);
+ hub.emit.apply(hub, args);
};
});
model.addMixin(pubs);
@@ -104,7 +105,7 @@ define([
if (instance) {
var subs = arr.map(lang.keys(model.subscribe), function (prop) {
var topic = model.subscribe[prop];
- return on(topic, instance[prop]);
+ return hub.on(topic, instance[prop]);
}),
commissioner = model.addCommissioner({
decommission: function (instance) {
View
@@ -15,11 +15,11 @@
define([
'../support/array',
'../support/compose',
- '../support/on',
+ '../support/Evented',
'../support/promise',
'../support/lang',
'../util/error'
-], function (arr, compose, listen, promise, lang, error) {
+], function (arr, compose, Evented, promise, lang, error) {
'use strict';
function Model(config) {
@@ -44,7 +44,7 @@ define([
}
}
- return compose(compose, listen.Evented, Model, {
+ return compose(compose, Evented, Model, {
// id must be unique per registry
id: '',
View
@@ -15,10 +15,10 @@
define([
'../support/array',
'../support/compose',
- '../support/on',
+ '../support/Evented',
'../util/error',
'../support/lang'
-], function (arr, compose, on, error, lang) {
+], function (arr, compose, Evented, error, lang) {
'use strict';
function Registry() {
@@ -36,7 +36,7 @@ define([
this._listeners = [];
}
- return compose(on.Evented, Registry, {
+ return compose(Evented, Registry, {
addModel: function (model) {
var services = this._services,
models = this._models,
@@ -12,7 +12,7 @@
*/
/*global define: false, require: false*/
-define(['dojo/on'], function (on) {
+define(['dojo/Evented'], function (Evented) {
'use strict';
- return on;
+ return Evented;
});

0 comments on commit 9ff7a5f

Please sign in to comment.