forked from cadence/out-of-your-element
		
	Only retrigger once, just in case
This commit is contained in:
		
							parent
							
								
									a2f0bb79db
								
							
						
					
					
						commit
						5a65e6f6da
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -18,7 +18,7 @@ const emitter = new EventEmitter()
 | 
			
		|||
 * Due to Eventual Consistency(TM) an update/delete may arrive before the original message arrives
 | 
			
		||||
 * (or before the it has finished being bridged to an event).
 | 
			
		||||
 * In this case, wait until the original message has finished bridging, then retrigger the passed function.
 | 
			
		||||
 * @template {(...args: any) => Promise<any>} T
 | 
			
		||||
 * @template {(...args: any[]) => Promise<any>} T
 | 
			
		||||
 * @param {string} messageID
 | 
			
		||||
 * @param {T} fn
 | 
			
		||||
 * @param {Parameters<T>} rest
 | 
			
		||||
| 
						 | 
				
			
			@ -32,7 +32,7 @@ function eventNotFoundThenRetrigger(messageID, fn, ...rest) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	debugRetrigger(`[retrigger] WAIT mid <-> eid = ${messageID} <-> ${eventID}`)
 | 
			
		||||
	emitter.addListener(messageID, () => {
 | 
			
		||||
	emitter.once(messageID, () => {
 | 
			
		||||
		debugRetrigger(`[retrigger] TRIGGER mid = ${messageID}`)
 | 
			
		||||
		fn(...rest)
 | 
			
		||||
	})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue