mirror of
https://github.com/Hopiu/postal.js.git
synced 2026-04-21 07:11:06 +00:00
31 lines
No EOL
651 B
JavaScript
31 lines
No EOL
651 B
JavaScript
define( [
|
|
'backbone',
|
|
'bus'
|
|
],
|
|
function( Backbone, bus ) {
|
|
"use strict";
|
|
|
|
return Backbone.Model.extend({
|
|
defaults: {
|
|
tweeters: []
|
|
},
|
|
|
|
initialize: function() {
|
|
var self = this;
|
|
this.subscriptions = [
|
|
bus.stats.subscribe( "tweet-count", function( data, env ){
|
|
if( data.tweeters && data.tweeters.length ) {
|
|
self.set( "tweeters", _.sortBy( data.tweeters, function( item ) { return item.count * -1; } ) );
|
|
}
|
|
})
|
|
];
|
|
},
|
|
|
|
dispose: function(){
|
|
_.each( this.subscriptions, function( subscription ){
|
|
subscription.unsubscribe();
|
|
});
|
|
this.clear( { silent: true } );
|
|
}
|
|
});
|
|
}); |