lib/rebus.js
function _loadFile(filename, callback) {
    callback = callback || function () { };

    if (filename.charAt(0) == '.') {
      callback();
      return;
    }

    var filepath = path.join(folder, filename);
    fs.readFile(filepath, function (err, data) {
      if (err) {
        console.error('Failed to read file ' + filepath + ' err:', err);
        callback(err);
        return;
      }
      try {
        _loadData(filename, data.toString());
      }
      catch (e) {
        console.info('Object ' + filename + ' was not yet fully written, exception:', e);
        // There will be another notification of change when the last write to file is completed.
        // Meanwhile leave the previous value.
        if (loader) {
          // Store this error to wait until file will be successfully loaded for the 1st time.
          loader.errors[filename] = e;
        }
        // Don't return error to continue asynchronous loading of other files. Errors are assembled on loader.
        callback();
        return;
      }
      console.log('Loaded ' + filename);
      if (loader) {
        if (loader.errors[filename]) {
          // File that previously failed to load, now is loaded.
          delete loader.errors[filename];
          var countErrors = Object.keys(loader.errors).length;
          if (countErrors === 0) {
            // All errors are fixed. This is the time to complete loading.
            var initcb = loader.callback;
            loader = null;
            _updateSingleton();
            initcb();
          }
        }
      }
      callback();
    });
  }
function _loadFile(filename, callback) {
    callback = callback || function () { };

    if (filename.charAt(0) == '.') {
      callback();
      return;
    }

    var filepath = path.join(folder, filename);
    fs.readFile(filepath, function (err, data) {
      if (err) {
        console.error('Failed to read file ' + filepath + ' err:', err);
        callback(err);
        return;
      }
      try {
        _loadData(filename, data.toString());
      }
      catch (e) {
        console.info('Object ' + filename + ' was not yet fully written, exception:', e);
        // There will be another notification of change when the last write to file is completed.
        // Meanwhile leave the previous value.
        if (loader) {
          // Store this error to wait until file will be successfully loaded for the 1st time.
          loader.errors[filename] = e;
        }
        // Don't return error to continue asynchronous loading of other files. Errors are assembled on loader.
        callback();
        return;
      }
      console.log('Loaded ' + filename);
      if (loader) {
        if (loader.errors[filename]) {
          // File that previously failed to load, now is loaded.
          delete loader.errors[filename];
          var countErrors = Object.keys(loader.errors).length;
          if (countErrors === 0) {
            // All errors are fixed. This is the time to complete loading.
            var initcb = loader.callback;
            loader = null;
            _updateSingleton();
            initcb();
          }
        }
      }
      callback();
    });
  }
function _loadFile ( filename , callback ) { callback = callback || function ( ) { } ; if ( filename . charAt ( 0 ) == '.' ) { callback ( ) ; return ; } var filepath = path . join ( folder , filename ) ; fs . readFile ( filepath , function ( err , data ) { if ( err ) { console . error ( 'Failed to read file ' + filepath + ' err:' , err ) ; callback ( err ) ; return ; } try { _loadData ( filename , data . toString ( ) ) ; } catch ( e ) { console . info ( 'Object ' + filename + ' was not yet fully written, exception:' , e ) ; // There will be another notification of change when the last write to file is completed.
 // Meanwhile leave the previous value.
 if ( loader ) { // Store this error to wait until file will be successfully loaded for the 1st time.
 loader . errors [ filename ] = e ; } // Don't return error to continue asynchronous loading of other files. Errors are assembled on loader.
 callback ( ) ; return ; } console . log ( 'Loaded ' + filename ) ; if ( loader ) { if ( loader . errors [ filename ] ) { // File that previously failed to load, now is loaded.
 delete loader . errors [ filename ] ; var countErrors = Object . keys ( loader . errors ) . length ; if ( countErrors === 0 ) { // All errors are fixed. This is the time to complete loading.
 var initcb = loader . callback ; loader = null ; _updateSingleton ( ) ; initcb ( ) ; } } } callback ( ) ; } ) ; }
Load object from a file. Update state and call notifications.
Load object from a file . Update state and call notifications .