mirror of
https://github.com/Hopiu/postal.js.git
synced 2026-04-24 08:34:48 +00:00
36 lines
No EOL
784 B
JavaScript
36 lines
No EOL
784 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;
|
|
} ) );
|
|
}
|
|
} ) ,
|
|
bus.app.subscribe( "search.init", function () {
|
|
self.set( "tweeters", [] );
|
|
} )
|
|
];
|
|
},
|
|
|
|
dispose : function () {
|
|
_.each( this.subscriptions, function ( subscription ) {
|
|
subscription.unsubscribe();
|
|
} );
|
|
this.clear( { silent : true } );
|
|
}
|
|
} );
|
|
} ); |