Permalink
Browse files

add updateAllViews to denormalizer

  • Loading branch information...
1 parent cfc25c2 commit fb09a7c2d890dacb7e07f6ccd341acca0dce5967 @petrjanda committed May 6, 2012
Showing with 22 additions and 1 deletion.
  1. +9 −1 lib/denormalizer.js
  2. +13 −0 spec/denormalizerSpec.js
View
@@ -35,6 +35,14 @@ Denormalizer.prototype.updateViews = function(event) {
})
}
+Denormalizer.prototype.updateAllViews = function() {
+ var self = this;
+
+ Object.keys(this.views).forEach(function(viewId) {
+ self.build(viewId);
+ })
+}
+
/*
* Build a given view using the most recent events.
*
@@ -45,6 +53,6 @@ Denormalizer.prototype.build = function(uid) {
if(!view) {
throw new Error('View is not registered!');
}
-
+
view.build();
}
View
@@ -38,6 +38,19 @@ describe('Denormalizer', function() {
})
describe('#updateViews', function() {
+ it('should trigger .build function for all registered views', function() {
+ var view = new View('foo', []);
+ spyOn(view, 'build');
+
+ denormalizer.registerView(view);
+
+ denormalizer.updateAllViews();
+
+ expect(view.build).toHaveBeenCalled();
+ })
+ })
+
+ describe('#updateAllViews', function() {
it('should trigger .build function for all registered views', function() {
var view = new View('foo', ['bar', 'baz']);
spyOn(view, 'build');

0 comments on commit fb09a7c

Please sign in to comment.