Add a generic CollectionView for handling live-updating collections.

Review Request #4269 — Created June 28, 2013 and submitted

david
Review Board
master
reviewboard
Add a generic CollectionView for handling live-updating collections.

This adds a utility view for rendering collections of things. To use this, one
extends this view with a new one that defines the itemViewType attribute. Items
can be added to the collection before or after the view is rendered, and the
results in the DOM will always match the current state of the collection.
Ran js-tests, used this in my post-commit view.
Description From Last Updated

I think this would be a bit clearer and more consistent with other code by grouping like: var .. this.foo ...

chipx86chipx86

With the version of backbone we're using, this could be: collection.on({ add: this._add, remove: this._remove }, this); Saves a few ...

chipx86chipx86

Can you add docs for all the functions?

chipx86chipx86

I assume this must be defined by subclasses as part of the object definition? If so, can you add: itemViewType: ...

chipx86chipx86

I recently updated the other like this to specifically say something like "... defined in the subclass's definition." I think ...

chipx86chipx86

Trailing comma.

chipx86chipx86

One per line.

chipx86chipx86

No trailing comma.

chipx86chipx86
chipx86
  1. 
      
  2. reviewboard/static/rb/js/views/collectionView.js (Diff revision 1)
     
     
     
     
     
     
     
     
    I think this would be a bit clearer and more consistent with other code by grouping like:
    
    var ..
    
    this.foo =
    this.bar =
    
    collection.each
    collection.on
  3. With the version of backbone we're using, this could be:
    
    collection.on({
        add: this._add,
        remove: this._remove
    }, this);
    
    
    Saves a few bytes.
  4. Can you add docs for all the functions?
  5. I assume this must be defined by subclasses as part of the object definition? If so, can you add:
    
        itemViewType: null
    
    To the top of CollectionView's definition.
  6. I recently updated the other like this to specifically say something like "... defined in the <classname> subclass's definition." I think that will help diagnose assertions.
  7. Trailing comma.
  8. 
      
david
chipx86
  1. Ship It!
  2. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (bf0d516).
Loading...