Skip to content

Instantly share code, notes, and snippets.

@Aldikitta
Created June 18, 2023 04:42
Show Gist options
  • Save Aldikitta/7e38ade047c4e1be55a6f50ce22a8233 to your computer and use it in GitHub Desktop.
Save Aldikitta/7e38ade047c4e1be55a6f50ce22a8233 to your computer and use it in GitHub Desktop.
val getListAgent: StateFlow<ListAgentVisit> = flow {
val agentList = useCase.getListAgentVisitWithFullResponse(
body = GetAgentVisitRequest(
branchCode = useCase.getAccountInfo().branchCode,
moId = useCase.getAccountInfo().employeeId,
skip = 1,
search = "",
prospectConsument = "",
agentProfessionCode = "",
startDate = "",
endDate = ""
)
).cachedIn(viewModelScope)
emit(ListAgentVisit(agentList = agentList))
}.stateIn(
viewModelScope,
SharingStarted.WhileSubscribed(5_000),
ListAgentVisit.default
)
data class ListAgentVisit(
val agentList: Flow<PagingData<GetAgentVisitResponse>>,
) {
companion object {
val default: ListAgentVisit = ListAgentVisit(
agentList = emptyFlow(),
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment