src/basis/data/dataset/Merge.js
function(source){
    // this -> sourceInfo
    var merge = this.owner;
    var sourcesMap_ = merge.sourcesMap_;
    var dataset = resolveDataset(this, merge.updateDataset_, source, 'adapter', merge);
    var inserted;
    var deleted;
    var delta;

    if (this.dataset === dataset)
      return;

    if (dataset)
    {
      var count = (sourcesMap_[dataset.basisObjectId] || 0) + 1;
      sourcesMap_[dataset.basisObjectId] = count;
      if (count == 1)
      {
        merge.addDataset_(dataset);
        inserted = [dataset];
      }
    }

    if (this.dataset)
    {
      var count = (sourcesMap_[this.dataset.basisObjectId] || 0) - 1;
      sourcesMap_[this.dataset.basisObjectId] = count;
      if (count == 0)
      {
        merge.removeDataset_(this.dataset);
        deleted = [this.dataset];
      }
    }

    this.dataset = dataset;

    // build delta and fire event
    merge.applyRule();

    // fire sources changes event
    if (delta = getDelta(inserted, deleted))
    {
      var setSourcesTransaction = merge.sourceDelta_;
      if (setSourcesTransaction)
      {
        if (delta.inserted)
          delta.inserted.forEach(function(item){
            if (!arrayRemove(this.deleted, item))
              arrayAdd(this.inserted, item);
          }, setSourcesTransaction);

        if (delta.deleted)
          delta.deleted.forEach(function(item){
            if (!arrayRemove(this.inserted, item))
              arrayAdd(this.deleted, item);
          }, setSourcesTransaction);
      }
      else
      {
        merge.emit_sourcesChanged(delta);
      }
    }

    return delta;
  }
function(source){
    // this -> sourceInfo
    var merge = this.owner;
    var sourcesMap_ = merge.sourcesMap_;
    var dataset = resolveDataset(this, merge.updateDataset_, source, 'adapter', merge);
    var inserted;
    var deleted;
    var delta;

    if (this.dataset === dataset)
      return;

    if (dataset)
    {
      var count = (sourcesMap_[dataset.basisObjectId] || 0) + 1;
      sourcesMap_[dataset.basisObjectId] = count;
      if (count == 1)
      {
        merge.addDataset_(dataset);
        inserted = [dataset];
      }
    }

    if (this.dataset)
    {
      var count = (sourcesMap_[this.dataset.basisObjectId] || 0) - 1;
      sourcesMap_[this.dataset.basisObjectId] = count;
      if (count == 0)
      {
        merge.removeDataset_(this.dataset);
        deleted = [this.dataset];
      }
    }

    this.dataset = dataset;

    // build delta and fire event
    merge.applyRule();

    // fire sources changes event
    if (delta = getDelta(inserted, deleted))
    {
      var setSourcesTransaction = merge.sourceDelta_;
      if (setSourcesTransaction)
      {
        if (delta.inserted)
          delta.inserted.forEach(function(item){
            if (!arrayRemove(this.deleted, item))
              arrayAdd(this.inserted, item);
          }, setSourcesTransaction);

        if (delta.deleted)
          delta.deleted.forEach(function(item){
            if (!arrayRemove(this.inserted, item))
              arrayAdd(this.deleted, item);
          }, setSourcesTransaction);
      }
      else
      {
        merge.emit_sourcesChanged(delta);
      }
    }

    return delta;
  }
function ( source ) { // this -> sourceInfo var merge = this . owner ; var sourcesMap_ = merge . sourcesMap_ ; var dataset = resolveDataset ( this , merge . updateDataset_ , source , 'adapter' , merge ) ; var inserted ; var deleted ; var delta ; if ( this . dataset === dataset ) return ; if ( dataset ) { var count = ( sourcesMap_ [ dataset . basisObjectId ] || 0 ) + 1 ; sourcesMap_ [ dataset . basisObjectId ] = count ; if ( count == 1 ) { merge . addDataset_ ( dataset ) ; inserted = [ dataset ] ; } } if ( this . dataset ) { var count = ( sourcesMap_ [ this . dataset . basisObjectId ] || 0 ) - 1 ; sourcesMap_ [ this . dataset . basisObjectId ] = count ; if ( count == 0 ) { merge . removeDataset_ ( this . dataset ) ; deleted = [ this . dataset ] ; } } this . dataset = dataset ; // build delta and fire event merge . applyRule ( ) ; // fire sources changes event if ( delta = getDelta ( inserted , deleted ) ) { var setSourcesTransaction = merge . sourceDelta_ ; if ( setSourcesTransaction ) { if ( delta . inserted ) delta . inserted . forEach ( function ( item ) { if ( ! arrayRemove ( this . deleted , item ) ) arrayAdd ( this . inserted , item ) ; } , setSourcesTransaction ) ; if ( delta . deleted ) delta . deleted . forEach ( function ( item ) { if ( ! arrayRemove ( this . inserted , item ) ) arrayAdd ( this . deleted , item ) ; } , setSourcesTransaction ) ; } else { merge . emit_sourcesChanged ( delta ) ; } } return delta ; }
Update dataset value by source.
@param {*} source
@private
Update dataset value by source .