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
🌞 Morning 338 commits ███▋░░░░░░░░░░░░░░░░░ 17.6% | |
🌆 Daytime 562 commits ██████▏░░░░░░░░░░░░░░ 29.2% | |
🌃 Evening 685 commits ███████▍░░░░░░░░░░░░░ 35.6% | |
🌙 Night 337 commits ███▋░░░░░░░░░░░░░░░░░ 17.5% |
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
struct Changes<Wrapped> { | |
private var version: UInt = 0 | |
var value: Wrapped { | |
didSet { version += 1 } | |
} | |
init(_ value: Wrapped) { | |
self.value = value | |
} | |
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
func render(for state: Observable<ViewModel.State>) { | |
state.map { $0.onProcess } | |
.distinctUntilChanged() | |
.bind(to: indicator.rx.isAnimating) | |
.disposed(by: disposeBag) | |
state.map { $0.searchResults } | |
.distinctUntilChanged() | |
.bind(to: tableView.rx.items(cellIdentifier: ReuseIdentifier.default)) { indexPath, searchResult, cell in | |
cell.configure(searchResult) |
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
func reduce(_ action: Action, for currentState: State) -> State { | |
switch action { | |
// from User | |
case .typeQuery(let query): | |
let newState = currentState.mutate { $0.query = query } | |
sideEffects.accept(.requestAutoCompletions(for: query)) | |
return newState | |
case .tapSearchButton: | |
let newState = currentState.mutate { $0.onProgress = true } |
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
func handle(_ sideEffect: SideEffect) -> Observable<Action> { | |
switch sideEffect { | |
case .requestAutoCompletions(let query): | |
let autoCompletion = // 비동기 로직 | |
return .just(.fetchAutoCompletion(autoCompletions)) | |
case .requestSearchs(let query): | |
let searchResults = // 비동기 로직 | |
return .just(.fetchSearchResult(searchResults)) | |
} |
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
enum SideEffect { | |
case requestAutoCompletions(for: String) | |
case requestSearchResults(for: String) | |
} |
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
func reduce(_ action: Action, for currentState: State) -> State { | |
switch action { | |
// from User | |
case .typeQuery(let query): | |
let newState = currentState.mutate { $0.query = query } | |
sideEffects.accept(.requestAutoCompletions(for: query)) | |
return newState | |
case .tapSearchButton: | |
let newState = currentState.mutate { $0.onProgress = true } |
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
struct State { | |
var onProgress: Bool // 로딩 여부 표현 | |
var query: String // 현재 입력된 query | |
var autoCompletions: [String] // 표현되는 자동 완성 문자열들 | |
var searchResults: [SearchResult] // 검색 결과 데이터 | |
} |
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
enum Action { | |
// from User | |
case typeQuery(String) // 검색어 입력 중 | |
case tapSearchButton // '검색' 버튼 클릭 | |
// from Side Effect | |
case fetchAutoCompletion([String]) // 자동 완성 문자열 요청에 대한 응답 도착 | |
case fetchSearchResult(SearchResult) // 검색 결과 요청에 대한 응답 도착 | |
} |
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
func reduce(_ action: Action) -> Observable<State> { | |
// API 요청 | |
// API 응답 값과 currentState(인자가 아닌 프로퍼티)를 수정한 newState 생성 | |
// newState 반환 | |
} |
NewerOlder