code: function(endType) {
  
          // create handler for specific end type (source|target).
          var onModelChange = function(endModel, opt) {
              this.onEndModelChange(endType, endModel, opt);
          };
  
          function watchEndModel(link, end) {
  
              end = end || {};
  
              var endModel = null;
              var previousEnd = link.previous(endType) || {};
  
              if (previousEnd.id) {
                  this.stopListening(this.paper.getModelById(previousEnd.id), 'change', onModelChange);
              }
  
              if (end.id) {
                  // If the observed model changes, it caches a new bbox and do the link update.
                  endModel = this.paper.getModelById(end.id);
                  this.listenTo(endModel, 'change', onModelChange);
              }
  
              onModelChange.call(this, endModel, { cacheOnly: true });
  
              return this;
          }
  
          return watchEndModel;
      }
docs: Returns a function observing changes on an end of the link. If a change happens and new end is a new model, it stops listening on the previous one and starts listening to the new one.