
var Pomodoro = Backbone.Model.extend({

    defaults: {
        isStarted: false,
        duration: 25 * 60,
        remainingSeconds: null
    },

    initialize: function() {
        this.listenTo(this, 'finished', this.finish);
    },

    start: function(duration){
        if (duration) {
            this.set('duration', duration);
        }

        this.set('isStarted', true);
        this.set('remainingSeconds', this.get('duration'));

        var that = this;
        this._interval = setInterval(function(){
            that.set('remainingSeconds', that.get('remainingSeconds') - 1);
            var remainingSeconds = that.get('remainingSeconds');
            that.trigger('countedDown', remainingSeconds);
            if (remainingSeconds === 0){
                that.trigger('finished');
            }
        }, 1000);
    },

    finish: function() {
        clearInterval(this._interval);
        this.stop();
    },

    stop: function() {
        this.set('isStarted', false);
        this.set('remainingSeconds', null);
    },

    onChange: function(callback) {
        this.listenTo(this, 'countedDown', callback);
    },

    onFinish: function(callback) {
        this.listenTo(this, 'finished', callback);
    }

});

module.exports = Pomodoro;

@@ -444,32 +444,138 @@
 ));%0A
-%0A        var that = this
+        this.trigger('countedDown', this.get('remainingSeconds'));%0A%0A        var that = this;%0A        clearInterval(this._interval)
 ;%0A  
@@ -854,18 +854,17 @@
 Seconds 
-==
+%3C
 = 0)%7B%0A  

Fix bug when starting pmdr multiple times