Last active
October 22, 2018 22:48
-
-
Save sanogueralorenzo/1e303499393becdd24926996a655d218 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val viewModelModule: Module = module { | |
viewModel { PostListViewModel(usersPostsUseCase = get()) } | |
viewModel { PostDetailsViewModel(userPostUseCase = get(), commentsUseCase = get()) } | |
} | |
val useCaseModule: Module = module { | |
factory { UsersPostsUseCase(userRepository = get(), postRepository = get()) } | |
factory { UserPostUseCase(userRepository = get(), postRepository = get()) } | |
factory { CommentsUseCase(commentRepository = get()) } | |
} | |
val repositoryModule: Module = module { | |
single { UserRepositoryImpl(userApi = get(), cache = get(USER_ENTITY_CACHE)) as UserRepository } | |
single { PostRepositoryImpl(postsApi = get(), cache = get(POST_ENTITY_CACHE)) as PostRepository } | |
single { CommentRepositoryImpl(commentsApi = get(), cache = get(COMMENT_ENTITY_CACHE)) as CommentRepository } | |
} | |
val networkModule: Module = module { | |
single { usersApi } | |
single { postsApi } | |
single { commentsApi } | |
} | |
val cacheModule: Module = module { | |
single(name = USER_ENTITY_CACHE) { Cache<List<UserEntity>>() } | |
single(name = POST_ENTITY_CACHE) { Cache<List<PostEntity>>() } | |
single(name = COMMENT_ENTITY_CACHE) { Cache<List<CommentEntity>>() } | |
} | |
private const val USER_ENTITY_CACHE = "USER_ENTITY_CACHE" | |
private const val POST_ENTITY_CACHE = "POST_ENTITY_CACHE" | |
private const val COMMENT_ENTITY_CACHE = "COMMENT_ENTITY_CACHE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment