copy db, connector, and type properties before handing them over to the connector, etc. This prevents some weird errors using y-elements
This commit is contained in:
		
							parent
							
								
									0521fac8d8
								
							
						
					
					
						commit
						6dd33f4f90
					
				
							
								
								
									
										10
									
								
								src/y.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/y.js
									
									
									
									
									
								
							@ -112,8 +112,6 @@ function Y (opts/* :YOptions */) /* :Promise<YConfig> */ {
 | 
			
		||||
    modules.push(opts.share[name])
 | 
			
		||||
  }
 | 
			
		||||
  return new Promise(function (resolve, reject) {
 | 
			
		||||
    setTimeout(function () {
 | 
			
		||||
      Y.requestModules(modules).then(function () {
 | 
			
		||||
    if (opts == null) reject('An options object is expected! ')
 | 
			
		||||
    else if (opts.connector == null) reject('You must specify a connector! (missing connector property)')
 | 
			
		||||
    else if (opts.connector.name == null) reject('You must specify connector name! (missing connector.name property)')
 | 
			
		||||
@ -121,15 +119,21 @@ function Y (opts/* :YOptions */) /* :Promise<YConfig> */ {
 | 
			
		||||
    else if (opts.connector.name == null) reject('You must specify db name! (missing db.name property)')
 | 
			
		||||
    else if (opts.share == null) reject('You must specify a set of shared types!')
 | 
			
		||||
    else {
 | 
			
		||||
      opts = Y.utils.copyObject(opts)
 | 
			
		||||
      opts.connector = Y.utils.copyObject(opts.connector)
 | 
			
		||||
      opts.db = Y.utils.copyObject(opts.db)
 | 
			
		||||
      opts.share = Y.utils.copyObject(opts.share)
 | 
			
		||||
      setTimeout(function () {
 | 
			
		||||
        Y.requestModules(modules).then(function () {
 | 
			
		||||
          var yconfig = new YConfig(opts)
 | 
			
		||||
          yconfig.db.whenUserIdSet(function () {
 | 
			
		||||
            yconfig.init(function () {
 | 
			
		||||
              resolve(yconfig)
 | 
			
		||||
            })
 | 
			
		||||
          })
 | 
			
		||||
        }
 | 
			
		||||
        }).catch(reject)
 | 
			
		||||
      }, 0)
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user