Skip to content

Commit

Permalink
[add] cat.dispose now also disposes actions all register actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Berkeley Martinez authored and Berkeley Martinez committed Dec 18, 2015
1 parent 2b9f3a2 commit 7c43146
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/Cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ const methods = {

dispose() {
debug('dispose all the things');
this.stores.forEach((store) => {
this.stores.forEach(store => {
store.dispose();
});

this.actions.forEach(action => {
action.dispose();
});
}
};

Expand Down
11 changes: 7 additions & 4 deletions test/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,14 @@ describe('Cat', function() {
// add observer to store
// in turn store observers actions
catStore.subscribe(() => {});
catStore.hasObservers().should.equal.true;
catActions.doAction.hasObservers().should.equal.true;
catStore.hasObservers().should.be.true;
catActions.doAction.subscribe(() => {});

catActions.doAction.hasObservers().should.be.true;
cat.dispose();
catStore.hasObservers().should.equal.false;
catActions.doAction.hasObservers().should.equal.false;

catStore.hasObservers().should.be.false;
catActions.doAction.hasObservers().should.equal(false);
});
});
});
Expand Down

0 comments on commit 7c43146

Please sign in to comment.