Skip to content
This repository has been archived by the owner on Jul 12, 2018. It is now read-only.

Commit

Permalink
The Model.class now inherits from Base.class
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Dec 14, 2014
1 parent a264b49 commit 6ba3ca6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 5 additions & 4 deletions lib/shared/Model.class.js
Expand Up @@ -5,6 +5,7 @@ var Class = require("alamid-class");
var Signal = require("alamid-signal");
var Junction = require("alamid-junction");
var EventEmitter = Class(require("events").EventEmitter);
var Base = require("./Base.class.js");
var modelStatics = require("./modelStatics.js");
var _ = require("underscore");
var log = require("./logger.js").get("shared");
Expand All @@ -25,10 +26,10 @@ var slice = Array.prototype.slice;

/**
* @class Model
* @extends EventEmitter
* @extends Base
* @mixins Junction
*/
var Model = EventEmitter.extend("Model", Junction, {
var Model = Base.extend("Model", Junction, {
/**
* Sets alamid-signal as Signal-class that will be used by alamid-junction
*/
Expand Down Expand Up @@ -900,8 +901,8 @@ var Model = EventEmitter.extend("Model", Junction, {
*/
dispose: function () {
Junction.prototype.dispose.call(this);
this.emit("dispose", new DisposeEvent(this));
this.removeAllListeners();

this._super();

// clearing references
this._ids = null;
Expand Down
9 changes: 3 additions & 6 deletions test/shared/Model.class.test.js
Expand Up @@ -839,13 +839,10 @@ describe("Model", function () {
});

it("should remove all event listeners", function () {
var hasBeenCalled = false;

user.removeAllListeners = function () {
hasBeenCalled = true;
};
user.on("some-event", function () {});
expect(Object.keys(user._events)).to.have.length(1);
user.dispose();
expect(hasBeenCalled).to.equal(true);
expect(Object.keys(user._events)).to.have.length(0);
});

it("should set the isDisposed-flag on true", function () {
Expand Down

0 comments on commit 6ba3ca6

Please sign in to comment.