mirror of
				https://github.com/AmberGraceRblx/luau-promise.git
				synced 2025-10-31 10:29:17 +00:00 
			
		
		
		
	Revert to using BindableEvents for await
This commit is contained in:
		
							parent
							
								
									601127071c
								
							
						
					
					
						commit
						154dc3cf9e
					
				
					 1 changed files with 17 additions and 17 deletions
				
			
		
							
								
								
									
										20
									
								
								lib/init.lua
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								lib/init.lua
									
									
									
									
									
								
							|  | @ -393,26 +393,26 @@ function Promise.prototype:await() | ||||||
| 	self._unhandledRejection = false | 	self._unhandledRejection = false | ||||||
| 
 | 
 | ||||||
| 	if self._status == Promise.Status.Started then | 	if self._status == Promise.Status.Started then | ||||||
| 		local ok, result, resultLength | 		local result | ||||||
|  | 		local resultLength | ||||||
|  | 		local bindable = Instance.new("BindableEvent") | ||||||
| 
 | 
 | ||||||
| 		local thread = coroutine.running() |  | ||||||
| 
 |  | ||||||
| 		spawn(function() |  | ||||||
| 		self:andThen( | 		self:andThen( | ||||||
| 			function(...) | 			function(...) | ||||||
| 				resultLength, result = pack(...) | 				resultLength, result = pack(...) | ||||||
| 					ok = true | 				bindable:Fire(true) | ||||||
| 			end, | 			end, | ||||||
| 			function(...) | 			function(...) | ||||||
| 				resultLength, result = pack(...) | 				resultLength, result = pack(...) | ||||||
| 					ok = false | 				bindable:Fire(false) | ||||||
| 			end | 			end | ||||||
| 			):finally(function() | 		) | ||||||
| 				coroutine.resume(thread) | 		self:finally(function() | ||||||
| 			end) | 			bindable:Fire(nil) | ||||||
| 		end) | 		end) | ||||||
| 
 | 
 | ||||||
| 		coroutine.yield() | 		local ok = bindable.Event:Wait() | ||||||
|  | 		bindable:Destroy() | ||||||
| 
 | 
 | ||||||
| 		if ok == nil then | 		if ok == nil then | ||||||
| 			-- If cancelled, we return nil. | 			-- If cancelled, we return nil. | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue