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

피드리스트를 받기 위한 UseCase, Entities,Repository를 정의했습니다. #4

Merged
merged 16 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -0,0 +1,24 @@
//
// FeedListRepository.swift
// HomeCafeRecipes
//
// Created by 김건호 on 6/10/24.
//

import RxSwift

protocol FeedListRepository {
func fetchRecipes() -> Observable<[Recipe]>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

옵저버블 자체로 반환하는 이유가 있을가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

서버에서 api 통신을 해서 Observable 자체로 return 시켜 비동기적으로 데이터를 처리해 보고 싶어서 사용했습니다

}

class DefaultFeedListRepository: FeedListRepository {
private let networkService: RecipeFetchService

init(networkService: RecipeFetchService) {
self.networkService = networkService
}

func fetchRecipes() -> Observable<[Recipe]> {
return networkService.fetchRecipes()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// SearchFeedListRepository.swift
// HomeCafeRecipes
//
// Created by 김건호 on 6/10/24.
//

import RxSwift

protocol SearchFeedListRepository {
func searchRecipes(title: String) -> Observable<[Recipe]>
}

class DefaultSearchFeedRepository: SearchFeedListRepository {

private let networkService: RecipeFetchService

init(networkService: RecipeFetchService) {
self.networkService = networkService
}

func searchRecipes(title: String) -> Observable<[Recipe]> {
return networkService.searchRecipes(title: title)
}
}