Skip to content

Instantly share code, notes, and snippets.

@thepearl
Last active January 14, 2021 17:12
Show Gist options
  • Save thepearl/ff849dab2d8e7798f2daf058f44fa749 to your computer and use it in GitHub Desktop.
Save thepearl/ff849dab2d8e7798f2daf058f44fa749 to your computer and use it in GitHub Desktop.
ViewModel init
import UIKit
import Combine
class ViewModel
{
var cancellables: Set<AnyCancellable> = []
init()
{
$keyWordSearch
.receive(on: RunLoop.main)
.debounce(for: .seconds(0.5), scheduler: RunLoop.main)
.sink { (_) in
self.fetchMovies()
}.store(in: &cancellables)
}
@Published var keyWordSearch: String = ""
var diffableDataSource: MoviesTableViewDiffableDataSource!
var snapshot = NSDiffableDataSourceSnapshot<String?, Result>()
func fetchMovies()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment