Coder Social home page Coder Social logo

omjoonkim / githubbrowserapp Goto Github PK

View Code? Open in Web Editor NEW
100.0 3.0 20.0 419 KB

GitHubBrowserApp on kotlin + rxJava2 + AAC+ retrofit2 + mvvm + koin + cleanArchitecture(modularization)

Java 0.17% Kotlin 99.83%
kotlin rxjava2 retrofit2 mvvm aac livedata viewmodel appcomponentfactory cleanarchitecture clean-architecture

githubbrowserapp's Issues

AppModule 내의 변수 접근 범위 변경 외 몇 가지

class AppModule(private val app: App) {
val applicationContexxt get() = app.applicationContext
val gson by lazy { Gson() }
val apiClient : APIClientType by lazy { APIClient(apiService) }
private val loggingInterceptor by lazy { HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY } }
private val okHttpClient by lazy {
OkHttpClient.Builder()
.readTimeout(10, TimeUnit.SECONDS)
.connectTimeout(10, TimeUnit.SECONDS)
.addInterceptor(loggingInterceptor)
.build()
}
private val apiService : APIService by lazy {
Retrofit.Builder()
.client(okHttpClient)
.baseUrl(APIService.EndPoint.baseUrl)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.build()
.create(APIService::class.java)
}
val gitHubDataRepository : GitHubRepositoryType by lazy { GitHubDataRepository(apiClient) }
val enviorment by lazy {
Environment(
apiClient,
gitHubDataRepository,
gson
)
}
}

AppModule.kt 내의 변수 접근 범위 변경

gson / apiClient / gitHubDataRepository 변수 모두 environment 라는 변수를 통해 제공이 되고 있습니다.
위의 변수들을 private 으로 두지 않는다면 environment 로서 따로 제공하는 의미가 없을 듯 합니다.

apiClient 변수 제거

gitHubDataRepositoryapiClient 를 Wrapping 하여 기능을 하고있습니다.
즉 environment 변수에서 apiClient 를 따로 제공할 필요가 없습니다.
실제로 environment 변수에서 apiClient 를 받아서 사용하는 경우가 존재하지 않습니다.

변수 오타 수정

enviroment -> environment

APIService 내의 Endpoint object

interface APIService {
object EndPoint {
const val baseUrl = "https://api.github.com"
}
@GET("/users/{userName}")
fun getUserInfo(@Path("userName") userName: String): Single<User>
@GET("/users/{userName}/repos")
fun getUserRepos(@Path("userName") userName: String): Single<List<Repo>>
}

Endpoint object 제거

Endpoint 라는 object name 에 baseUrl 밖에 존재하지 않습니다.
endpoint 변수를 추가한다면 필요한 object 가 되겠으나 현재 그렇게 사용하고 있지 않으니 제거하는 것이 어떨까요?

baseUrl 위치 변경

baseUrl 자체를 build.gradle 내의 buildConfigField 변수로 정의해놓는 것이 어떨까요?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.