Adds set method to MutableDataSource
This commit is contained in:
		
							parent
							
								
									98999c754f
								
							
						
					
					
						commit
						b9b0e84704
					
				| @ -25,6 +25,9 @@ interface DataSource<T> { | ||||
| } | ||||
| 
 | ||||
| interface MutableDataSource<T> : DataSource<T> { | ||||
| 
 | ||||
|     suspend fun set(value: T) | ||||
| 
 | ||||
|     fun post(value: T) | ||||
| } | ||||
| 
 | ||||
| @ -42,6 +45,10 @@ open class BehaviorDataSource<T>(private val defaultValue: T? = null) : MutableD | ||||
|         return mutableFlow | ||||
|     } | ||||
| 
 | ||||
|     override suspend fun set(value: T) { | ||||
|         mutableFlow.emit(value) | ||||
|     } | ||||
| 
 | ||||
|     override fun post(value: T) { | ||||
|         mutableFlow.tryEmit(value) | ||||
|     } | ||||
| @ -58,6 +65,10 @@ open class PublishDataSource<T> : MutableDataSource<T> { | ||||
|         return mutableFlow | ||||
|     } | ||||
| 
 | ||||
|     override suspend fun set(value: T) { | ||||
|         mutableFlow.emit(value) | ||||
|     } | ||||
| 
 | ||||
|     override fun post(value: T) { | ||||
|         mutableFlow.tryEmit(value) | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user