forked from MapComplete/MapComplete
		
	Fix the broken initial location
This commit is contained in:
		
							parent
							
								
									ba63ac7248
								
							
						
					
					
						commit
						f5b2ba6a06
					
				
					 4 changed files with 19 additions and 11 deletions
				
			
		|  | @ -77,13 +77,15 @@ export class UIEventSource<T>{ | |||
|     } | ||||
| 
 | ||||
|      | ||||
|     public syncWith(otherSource: UIEventSource<T>) : UIEventSource<T>{ | ||||
|     public syncWith(otherSource: UIEventSource<T>, reverseOverride = false): UIEventSource<T> { | ||||
|         this.addCallback((latest) => otherSource.setData(latest)); | ||||
|         const self = this; | ||||
|         otherSource.addCallback((latest) => self.setData(latest)); | ||||
|         if(this.data === undefined){ | ||||
|            this.setData(otherSource.data); | ||||
|         }else{ | ||||
|         if (reverseOverride && otherSource.data !== undefined) { | ||||
|             this.setData(otherSource.data); | ||||
|         } else if (this.data === undefined) { | ||||
|             this.setData(otherSource.data); | ||||
|         } else { | ||||
|             otherSource.setData(this.data); | ||||
|         } | ||||
|         return this; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue