-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Feature] 화이트보드 입장 핸들링 #141
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4fad33c
feature: 연결 성공 여부 전달
ekrud99 4e3c06c
feature: 연결 결과에 따른 처리
ekrud99 54c829a
style: 메서드 명 변경
ekrud99 739264c
fix: timeout 이후에 연결 성공 시 disconnect
ekrud99 dfedc22
style: 컨벤션 수정
ekrud99 cb7f867
fix: WhiteboardRepositoryInterface 프로토콜 준수
ekrud99 2d365bb
refactor: 접근 제어자 변경
ekrud99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,9 @@ public final class WhiteboardUseCase: WhiteboardUseCaseInterface { | |
private var profileRepository: ProfileRepositoryInterface | ||
private let whiteboardListSubject: CurrentValueSubject<[Whiteboard], Never> | ||
public let whiteboardListPublisher: AnyPublisher<[Whiteboard], Never> | ||
private let whiteboardConnectionSubject: PassthroughSubject<Bool, Never> | ||
public let whiteboardConnectionPublisher: AnyPublisher<Bool, Never> | ||
private var cancellables: Set<AnyCancellable> | ||
|
||
public init( | ||
whiteboardRepository: WhiteboardRepositoryInterface, | ||
|
@@ -22,6 +25,9 @@ public final class WhiteboardUseCase: WhiteboardUseCaseInterface { | |
self.profileRepository = profileRepository | ||
whiteboardListSubject = CurrentValueSubject<[Whiteboard], Never>([]) | ||
whiteboardListPublisher = whiteboardListSubject.eraseToAnyPublisher() | ||
whiteboardConnectionSubject = PassthroughSubject<Bool, Never>() | ||
whiteboardConnectionPublisher = whiteboardConnectionSubject.eraseToAnyPublisher() | ||
cancellables = [] | ||
self.whiteboardRepository.delegate = self | ||
} | ||
|
||
|
@@ -48,12 +54,28 @@ public final class WhiteboardUseCase: WhiteboardUseCaseInterface { | |
|
||
public func joinWhiteboard(whiteboard: Whiteboard) throws { | ||
let profile = profileRepository.loadProfile() | ||
bindConnectionResult() | ||
try whiteboardRepository.joinWhiteboard(whiteboard: whiteboard, myProfile: profile) | ||
} | ||
|
||
public func startSearchingWhiteboards() { | ||
whiteboardRepository.startSearching() | ||
} | ||
|
||
private func bindConnectionResult() { | ||
whiteboardRepository.connectionResultPublisher | ||
.timeout(.seconds(3), scheduler: DispatchQueue.main) | ||
.first() | ||
.replaceEmpty(with: false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오우 이 오퍼레이터 동작 방식이 궁금합니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
.sink { [weak self] isConnected in | ||
if isConnected { | ||
self?.whiteboardConnectionSubject.send(true) | ||
} else { | ||
self?.whiteboardConnectionSubject.send(false) | ||
} | ||
} | ||
.store(in: &cancellables) | ||
} | ||
} | ||
|
||
extension WhiteboardUseCase: WhiteboardRepositoryDelegate { | ||
|
This file contains 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
This file contains 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
This file contains 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 얘가 보내는 값은 별로 중요하지 않은 건가요 ?? 항상 true를 보내고 UseCase에서 분기처리 ? ? ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
뭔가
false
를 보내줄 일이 있지 않을까.. 해서 남겨놓았습니다만..조이가 보신대로
true
를 보내주는 코드만 존재합니다.변경하는게 맞을까요?
일단
true
를 보내는 이유는 연결에 성공했기 때문입니다~!