| 
									
										
										
										
											2019-05-23 02:11:16 +08:00
										 |  |  | const connectToDB = async url => { | 
					
						
							|  |  |  | 	await new Promise(r => setTimeout(r, 1000)); | 
					
						
							| 
									
										
										
										
											2019-05-23 15:18:06 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2019-05-23 02:11:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-23 15:18:06 +08:00
										 |  |  | // This is a top-level-await
 | 
					
						
							| 
									
										
										
										
											2019-05-23 02:11:16 +08:00
										 |  |  | await connectToDB("my-sql://example.com"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export const dbCall = async data => { | 
					
						
							| 
									
										
										
										
											2019-05-23 15:18:06 +08:00
										 |  |  | 	// This is a normal await, because it's in an async function
 | 
					
						
							| 
									
										
										
										
											2019-05-23 02:11:16 +08:00
										 |  |  | 	await new Promise(r => setTimeout(r, 100)); | 
					
						
							|  |  |  | 	return "fake data"; | 
					
						
							| 
									
										
										
										
											2019-05-23 15:18:06 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export const close = () => { | 
					
						
							|  |  |  | 	console.log("closes the DB connection"); | 
					
						
							|  |  |  | }; |