JavaScript
- 15 ответов
 - 0 вопросов
 
    8
    Вклад в тег
    
      
      
    
  
  
this.start = function(){
    // останавливаем репликацию
    return this.stopAndClearExistsReplication()
        // удаляем локальную БД
        .always(function(){ return this.deleteLocalDB() })
        // создаём локальную БД
        .always(function(){ return this.createLocalDB() })
        // ставим БД на репликацию
        .done(function(){ return this.addReplicationDocument() })
        // ставим репликацию на отслеживание
        .done(function(){ return this.replicationMonitoring() });
};this.start = function(){
    // останавливаем репликацию
    return this.stopAndClearExistsReplication()
        // удаляем локальную БД
        .always(deleteLocalDB)
        // создаём локальную БД
        .always(createLocalDB)
        // ставим БД на репликацию
        .done(addReplicationDocument)
        // ставим репликацию на отслеживание
        .done();
};
function deleteLocalDB(){ return this.deleteLocalDB() }
function createLocalDB(){ return this.createLocalDB() }
function addReplicationDocument(){ return this.addReplicationDocument() }
function replicationMonitoring(){ return this.replicationMonitoring() }this.start = function(){
    // останавливаем репликацию
    return this.stopAndClearExistsReplication()
        // удаляем локальную БД
        .always(() => this.deleteLocalDB())
        // создаём локальную БД
        .always(() =>  this.createLocalDB())
        // ставим БД на репликацию
        .done(() => this.addReplicationDocument())
        // ставим репликацию на отслеживание
        .done(() =>  this.replicationMonitoring());
};this.start = function(){
    return Promise.resolve()
        .then(() =>  this.stopAndClearExistsReplication())
        .always(() => this.deleteLocalDB())
        .always(() =>  this.createLocalDB())
        .done(() => this.addReplicationDocument())
        .done(() =>  this.replicationMonitoring());
};      $(function(){
  // Для первого способа можно изменять объект, зная что эти изменения видны всем
  App.prop1 = true;
  // Для прототипов изменения App1 не отражаются родительском App
  var App1 = new App();
  App1.prop1 = true;
});
$(function(){
  // Для первого случая есть изменения
  console.log(App.prop1); // true
  // Для второго случая создается новый потомок, который ничего не знает о других потомках
  var App1 = new App();
  console.log(App.prop1); // undefined
});