Skip to content

Conversation

@Jhw9n
Copy link
Collaborator

@Jhw9n Jhw9n commented Dec 17, 2025

🍎 작업 내용

  1. 영화 Api
image
  1. MovieAPI, MovieService, NowPlayingResponseDTO 파일 생성

MovieAPI : 어떤 API를, 어떤 방식으로 호출할지 정의하는 곳

extension MovieAPI: TargetType {
    var baseURL      // 서버 주소
    var path         // 엔드포인트 경로
    var method       // HTTP 메서드
    var task         // 파라미터 / 바디
    var headers      // 헤더
}

MovieService : API 명세(MovieAPI)를 실제 HTTP 요청으로 실행하는 계층

final class MovieService {
    let provider = MoyaProvider<MovieAPI>()
}

NowPlayingResponseDTO : now_playing API의 JSON 전체 구조를 그대로 표현한 모델

struct NowPlayingResponseDTO: Codable
  1. Moya + Combine 패턴 (MovieViewModel)
final class MovieViewModel: ObservableObject {
    @Published var movies: [MovieModel] = []
    private var cancellables = Set<AnyCancellable>()

@published movies
→ View에서 자동으로 리렌더링
• cancellables
→ 네트워크 스트림 생명주기 관리

service.requestPublisher(.nowPlaying(page: 1))
    .map(\.data)
    .decode(type: NowPlayingResponseDTO.self, decoder: JSONDecoder())
    .map { dto in
        dto.results.map { MovieModel(...) }
    }
    .receive(on: DispatchQueue.main)
    .sink(...)
  1. 뷰에서 불러옴
.onAppear {
    viewModel.fetchNowPlaying()
}

📷 스크린샷

💬 리뷰 코멘트

더 자세히 적고 싶었는데, 진짜정말루 시간이 없어서 부족한 점 죄송합니다ㅠㅠ
다들 너무너무 고생 많았고 앱잼에서도 컴바인 잘 사용해봐요!!
스장님 최고 👍

Copy link
Collaborator

@y-eonee y-eonee left a comment

Choose a reason for hiding this comment

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

수고많으셨습니당 ㅎㅎ


private var MovieChart: some View {
VStack(alignment: .leading, spacing: 12) {
ScrollView(.horizontal, showsIndicators: false) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기부분 뎁스가 좀 깊은것같은데 리팩해봐도좋을듯여

Comment on lines +9 to +10
import Moya
import Alamofire
Copy link
Collaborator

Choose a reason for hiding this comment

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

오....모야랑 알라모를 둘다쓴이유가 무엇이죠

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants