Skip to content

Commit

Permalink
bug: base class should use the right publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
baccigalupi committed Aug 29, 2012
1 parent da29820 commit f9c1378
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions spec/javascripts/class/base_spec.js
Expand Up @@ -279,12 +279,12 @@ describe('Wheel.Base', function() {
describe('#publish', function() {
describe('when there is a publisher', function() {
beforeEach(function() {
Wheel.Publisher = Wheel.Base.build();
base._publisher = Wheel.Base.build();
});

it('calls trigger on the publisher', function() {
var active;
Wheel.Publisher.on('active', function() {
base._publisher.on('active', function() {
active = true;
});

Expand All @@ -296,7 +296,7 @@ describe('Wheel.Base', function() {
var expectedData = {foo: 'bar'};

var called;
Wheel.Publisher.on('foo', function(data) {
base._publisher.on('foo', function(data) {
expect(data).toEqual(expectedData);
called = true;
});
Expand All @@ -308,7 +308,6 @@ describe('Wheel.Base', function() {
});
});


describe('#subscribe', function() {
describe('when a publisher is available', function() {
beforeEach(function() {
Expand Down
4 changes: 2 additions & 2 deletions src/class/base.js
Expand Up @@ -37,12 +37,12 @@ Wheel._Class.subclass('Wheel.Base', {

publish: function(eventType, eventData) {
this._publisher || this._findPublisher();
Wheel.Publisher.trigger(eventType, eventData);
this._publisher.trigger(eventType, eventData);
},

subscribe: function(eventName, callback, context) {
this._publisher || this._findPublisher();
Wheel.Publisher.on(eventName, callback, context || this);
this._publisher.on(eventName, callback, context || this);
},

_findPublisher: function() {
Expand Down

0 comments on commit f9c1378

Please sign in to comment.