mirror of
https://github.com/Hopiu/postal.js.git
synced 2026-03-16 22:20:23 +00:00
33 lines
No EOL
643 B
JavaScript
33 lines
No EOL
643 B
JavaScript
define( [
|
|
'backbone'
|
|
],
|
|
function ( Backbone ) {
|
|
"use strict";
|
|
|
|
return function( defaults, subscriptions ) {
|
|
var model = new (Backbone.Model.extend( {
|
|
|
|
initialize : function () {
|
|
_.bindAll( this );
|
|
this.subscriptions = [];
|
|
},
|
|
|
|
dispose : function () {
|
|
if( this.subscriptions ) {
|
|
_.each( this.subscriptions, function ( subscription ) {
|
|
subscription.unsubscribe();
|
|
} );
|
|
}
|
|
this.clear( { silent : true } );
|
|
}
|
|
}))( defaults );
|
|
|
|
_.each( subscriptions, function( sub ){
|
|
sub.withContext( model );
|
|
});
|
|
|
|
model.subscriptions = subscriptions ;
|
|
|
|
return model;
|
|
};
|
|
} ); |