// Dep: [KadOH]/core/eventemitter

(function(exports) {

  var KadOH        = exports,
      EventEmitter = KadOH.core.EventEmitter;

  KadOH.core = KadOH.core || {};
  var Deferred = KadOH.core.StateEventEmitter = EventEmitter.extend({
    
    initialize: function() {
      this.supr();
      this.state = null;
    },

    /**
     * Set state of the object and emit an event whose name is the given state. 
     * 
     * You can pass additional arguments that will be emited with.
     * 
     * @example
     * obj.setState('connecting', 'google.com'); 
     * //will do :
     * obj.emit('connecting', 'google.com');
     * 
     * @param {String}  state       the state to set
     * @param {*}       [add_args]  additionals arguments that will be passed in emit after the state
     *
     * @return {self}   this
     */
    setState: function(state) {
      this.setStateSilently(state);
      this.emit.apply(this, arguments);
      return this;
    },

    /**
     * Set state but don't emit any event.
     * @param {String} state the state to set
     * 
     * @return {self} this
     */
    setStateSilently: function(state) {
      this.state = String(state);
      return this;
    },

    /**
     * Getter for the state of the object.
     * @return {String} state
     */
    getState: function() {
      return this.state;
    },

    /**
     * Match tester for the state of the object.
     * @param  {String} state state to be tested
     * @return {Booelean} result of the test
     */
    stateIs: function(state) {
      return this.state === state;
    },

    /**
     * Not match tester for the state of the object.
     * @param  {String} state state to be tested
     * @return {Booelean} result of the test
     */
    stateIsNot: function(state) {
      return this.state !== state;
    }

  });

})('object' === typeof module ? module.exports : (this.KadOH = this.KadOH || {}));

@@ -889,24 +889,25 @@
 tly(state);%0A
+%0A
       this.e
@@ -934,16 +934,444 @@
 ments);%0A
+      this.emit('state change', state);%0A%0A      return this;%0A    %7D,%0A%0A    /**%0A     * Attach a callback to the event corresponding of changing statte. Callback willl be called with state as argument.%0A     * @param  %7BFunction%7D cb        Callback to call%0A     * @param  %7BObject%7D   %5Bcontext%5D Context of callback%0A     * @return %7Bself%7D this%0A     */%0A    onStateChange: function(cb, context) %7B%0A      this.on('state change', cb, context);%0A
       re

add 'state change' event