code: function() {
          this.listeners = {};
          for(var type in this.registry) {
              this.listeners[type] = OpenLayers.Function.bind(function() {
                  if(!this.restoring) {
                      var state = this.registry[type].apply(this, arguments);
                      this.previousStack.unshift(state);
                      if(this.previousStack.length > 1) {
                          this.onPreviousChange(
                              this.previousStack[1], this.previousStack.length - 1
                          );
                      }
                      if(this.previousStack.length > (this.limit + 1)) {
                          this.previousStack.pop();
                      }
                      if(this.nextStack.length > 0) {
                          this.nextStack = [];
                          this.onNextChange(null, 0);
                      }
                  }
                  return true;
              }, this);
          }
      }
docs: Method: setListeners
  Sets functions to be registered in the listeners object.