Skip to content

Commit

Permalink
#156 #158 feat: 음악 검색을 중지했을 경우 작동하는 로직 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
radiantchoi committed Dec 6, 2022
1 parent 222b58f commit 1fd2474
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
9 changes: 7 additions & 2 deletions Segno/Segno/Data/Repository/MusicRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@
import RxSwift

protocol MusicRepository {
func searchMusic()
func startSearchingMusic()
func stopSearchingMusic()
func playMusic()
}

final class MusicRepositoryImpl: MusicRepository {
private let shazamSession = ShazamSession()
private let musicSession = MusicSession()

func searchMusic() {
func startSearchingMusic() {

}

func stopSearchingMusic() {
shazamSession.stop()
}

func playMusic() {

}
Expand Down
15 changes: 13 additions & 2 deletions Segno/Segno/Domain/UseCase/SearchMusicUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,26 @@
import RxSwift

protocol SearchMusicUseCase {
func searchMusic() -> Single<MusicInfo>
func startSearching() -> Single<MusicInfo>
func stopSearching()
}

final class SearchMusicUseCaseImpl: SearchMusicUseCase {
func searchMusic() -> Single<MusicInfo> {
let musicRepository: MusicRepository

init(musicRepository: MusicRepository = MusicRepositoryImpl()) {
self.musicRepository = musicRepository
}

func startSearching() -> Single<MusicInfo> {
// 음악을 검색해줄 것을 레포지토리에 요청

return Single.create { _ in
return Disposables.create()
}
}

func stopSearching() {
musicRepository.stopSearchingMusic()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ extension DiaryEditViewController {

private func searchTapped() {
shazamSession.toggleSearch() // 지워질 예정
viewModel.searchMusic()
viewModel.startSearchingMusic()
.observe(on: MainScheduler.instance)
.subscribe(onSuccess: { info in
self.musicInfoLabel.text = "\(info.artist) - \(info.title)"
Expand Down
8 changes: 6 additions & 2 deletions Segno/Segno/Presentation/ViewModel/DiaryEditViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ final class DiaryEditViewModel {

}

func searchMusic() -> Single<MusicInfo> {
return searchMusicUseCase.searchMusic()
func startSearchingMusic() -> Single<MusicInfo> {
return searchMusicUseCase.startSearching()
}

func stopSearchingMusic() {
searchMusicUseCase.stopSearching()
}

func setLocation() {
Expand Down

0 comments on commit 1fd2474

Please sign in to comment.