Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor getChoreList #26

Merged
merged 1 commit into from
May 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ package com.depromeet.housekeeper

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.depromeet.housekeeper.adapter.AddTodo1ChoreAdapter
import com.depromeet.housekeeper.model.ChoreList
import com.depromeet.housekeeper.network.remote.repository.Repository
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import timber.log.Timber

class AddTodoFragment1ViewModel : ViewModel() {
init {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@ package com.depromeet.housekeeper.network.remote.repository

import com.depromeet.housekeeper.model.ChoreList
import com.depromeet.housekeeper.model.HouseWorks
import com.depromeet.housekeeper.network.remote.api.ChoreListApi
import com.depromeet.housekeeper.network.remote.api.RemoteDataSource
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow

object Repository : RemoteDataSource {
private val ApiService = RetrofitBuilder.apiService
private val ChoreListApi = RetrofitBuilder.ChoreList
private val apiService = RetrofitBuilder.apiService
override suspend fun getList(scheduledDate: String): Flow<HouseWorks> = flow {
ApiService.getList(scheduledDate)
emit(apiService.getList(scheduledDate))
}

override suspend fun getHouseWorkList(space:String): Flow<ChoreList> = flow {
ApiService.getChoreList(space)
emit(value = ApiService.getChoreList(space))

override suspend fun getHouseWorkList(space: String): Flow<ChoreList> = flow {
emit(apiService.getChoreList(space))
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.depromeet.housekeeper.network.remote.repository

import com.depromeet.housekeeper.network.remote.api.ApiService
import com.depromeet.housekeeper.network.remote.api.ChoreListApi
import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import retrofit2.create

object RetrofitBuilder {
private const val BASE_URL = "http://ec2-13-125-232-180.ap-northeast-2.compute.amazonaws.com:8080"
Expand All @@ -31,5 +29,4 @@ object RetrofitBuilder {
.build()

val apiService: ApiService = retrofit.create(ApiService::class.java)
val ChoreList : ChoreListApi = retrofit.create(ChoreListApi::class.java)
}