-
Notifications
You must be signed in to change notification settings - Fork 2
๐ :: (#379) ๋ง์ดํ์ด์ง ์์ธ ReactorKit #380
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1b4058e
โจ :: (#379) ๋ฒ๊ทธ ์ ๋ณด Reactor
leejh08 9d63896
โจ :: (#379) ์๋ฆผ ์ค์ Reactor
leejh08 bf28425
โจ :: (#379) ๊ด์ฌ๋ถ์ผ Reactor
leejh08 3066acd
๐๏ธ :: (#379) viewWillappear -> fetch
leejh08 d509d60
โจ :: (#379) ๊ด์ฌ๋ถ์ผ ์ ํ ํ ์๋ pop
leejh08 2f664be
โจ :: (#379) api ํธ์ถ ํ ๋ทฐ ์ด๋ ํ๋ก์ฐ
leejh08 64036a1
๐๏ธ :: (#379) ๋งคํ ์๋ฌ ์์
leejh08 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
110 changes: 110 additions & 0 deletions
110
Projects/Presentation/Sources/BugReport/BugReportReactor.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| import ReactorKit | ||
| import RxSwift | ||
| import RxCocoa | ||
| import RxFlow | ||
| import Core | ||
| import Domain | ||
|
|
||
| public final class BugReportReactor: BaseReactor, Stepper { | ||
| public let steps = PublishRelay<Step>() | ||
| public let initialState: State | ||
| private let reportBugUseCase: ReportBugUseCase | ||
|
|
||
| public init( | ||
| reportBugUseCase: ReportBugUseCase | ||
| ) { | ||
| self.initialState = .init() | ||
| self.reportBugUseCase = reportBugUseCase | ||
| } | ||
|
|
||
| public enum Action { | ||
| case updateTitle(String) | ||
| case updateContent(String) | ||
| case updateImageList([String]) | ||
| case updateMajorType(String) | ||
| case majorViewDidTap | ||
| case bugReportButtonDidTap | ||
| } | ||
|
|
||
| public enum Mutation { | ||
| case setTitle(String) | ||
| case setContent(String) | ||
| case setImageList([String]) | ||
| case setMajorType(String) | ||
| case setBugReportButtonIsEnabled(Bool) | ||
| case setBugReportCompleted | ||
| } | ||
|
|
||
| public struct State { | ||
| var title: String = "" | ||
| var content: String = "" | ||
| var imageList: [String] = [] | ||
| var majorType: String = "์ ์ฒด" | ||
| var isBugReportButtonEnabled: Bool = false | ||
| var isBugReportCompleted: Bool = false | ||
| } | ||
| } | ||
|
|
||
| extension BugReportReactor { | ||
| public func mutate(action: Action) -> Observable<Mutation> { | ||
| switch action { | ||
| case let .updateTitle(title): | ||
| let isEnabled = !title.isEmpty && !currentState.content.isEmpty | ||
| return .concat([ | ||
| .just(.setTitle(title)), | ||
| .just(.setBugReportButtonIsEnabled(isEnabled)) | ||
| ]) | ||
|
|
||
| case let .updateContent(content): | ||
| let isEnabled = !currentState.title.isEmpty && !content.isEmpty | ||
| return .concat([ | ||
| .just(.setContent(content)), | ||
| .just(.setBugReportButtonIsEnabled(isEnabled)) | ||
| ]) | ||
|
|
||
| case let .updateImageList(imageList): | ||
| return .just(.setImageList(imageList)) | ||
|
|
||
| case let .updateMajorType(majorType): | ||
| return .just(.setMajorType(majorType)) | ||
|
|
||
| case .majorViewDidTap: | ||
| steps.accept(BugReportStep.majorBottomSheetIsRequired) | ||
| return .empty() | ||
|
|
||
| case .bugReportButtonDidTap: | ||
| return reportBugUseCase.execute(req: .init( | ||
| title: currentState.title, | ||
| content: currentState.content, | ||
| developmentArea: DevelopmentType(localizedString: currentState.majorType) ?? .all, | ||
| attachmentUrls: currentState.imageList | ||
| )) | ||
| .asObservable() | ||
| .map { _ in Mutation.setBugReportCompleted } | ||
| } | ||
| } | ||
|
|
||
| public func reduce(state: State, mutation: Mutation) -> State { | ||
| var newState = state | ||
| switch mutation { | ||
| case let .setTitle(title): | ||
| newState.title = title | ||
|
|
||
| case let .setContent(content): | ||
| newState.content = content | ||
|
|
||
| case let .setImageList(imageList): | ||
| newState.imageList = imageList | ||
|
|
||
| case let .setMajorType(majorType): | ||
| newState.majorType = majorType | ||
|
|
||
| case let .setBugReportButtonIsEnabled(isEnabled): | ||
| newState.isBugReportButtonEnabled = isEnabled | ||
|
|
||
| case .setBugReportCompleted: | ||
| newState.isBugReportCompleted = true | ||
| } | ||
| return newState | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.