Created
July 20, 2020 23:55
-
-
Save serhiybutz/578ae9b7860d28da24a956d8fad60de6 to your computer and use it in GitHub Desktop.
Combine: withLatestFrom, 02
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
var cancellables = Set<AnyCancellable>() | |
func setupPipelines() { | |
let searchPublisher = searchBar.searchTextField.textPublisher | |
.prepend(searchBar.text!) | |
.eraseToAnyPublisher() | |
let sparsedSearchPublisher = searchPublisher | |
.debounce(for: .seconds(0.3), scheduler: DispatchQueue.main) | |
.eraseToAnyPublisher() | |
sparsedSearchPublisher | |
.sink( | |
receiveValue: { searchText in | |
self.doSearching(by: searchText ?? "") | |
}) | |
.store(in: &cancellables) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment