I am using datastore for user data to store and us...
# flow
d
I am using datastore for user data to store and use it in REST api call (for example token and/or userId) for verification. Main issue is REST api is called in form of Flow too and i need to send value of other flows from DataStore. Anyone can tell me how to send multiple flows data in another one.?
Copy code
@HiltViewModel
class UserViewModel @Inject constructor(
   private var userRepository: UserRepository,
   val session: Session,
) : ViewModel() {
   val isLoggedIn: StateFlow<Boolean> = session.isUserLoggedIn().stateIn(
      scope = viewModelScope, started = SharingStarted.WhileSubscribed(), initialValue = false
   )
   val id = session.userId().stateIn(
      scope = viewModelScope, initialValue = 0, started = SharingStarted.WhileSubscribed()
   )
   val token = session.loginToken().stateIn(
      scope = viewModelScope, initialValue = "", started = SharingStarted.WhileSubscribed()
   )

	private val _search = MutableStateFlow("")
	
	val search = _search.asStateFlow()
		.stateIn(
			scope = viewModelScope,
			started = SharingStarted.WhileSubscribed(),
			initialValue = "",
		)
	
	@OptIn(FlowPreview::class, ExperimentalCoroutinesApi::class)
	val searchedDataFlow = search.debounce(300.milliseconds).flatMapLatest { query ->
		userRepository.getAllMember(
			id.value, query, token = token.value,
			bloodGroupId, educationId,
			businessId, villageId
		).cachedIn(viewModelScope)
	}   
}
This is my viewmodel class, I have tried using .value but sometimes i get value in rest api and sometime dont.