Skip to content

Instantly share code, notes, and snippets.

@DhavalDobariya86
Last active June 9, 2020 21:08
Show Gist options
  • Save DhavalDobariya86/00b47b0ef9f5db38e6d7ba65c21c5620 to your computer and use it in GitHub Desktop.
Save DhavalDobariya86/00b47b0ef9f5db38e6d7ba65c21c5620 to your computer and use it in GitHub Desktop.
ViewModel protocol
import Foundation
/// This protocol defines basic responsibility for `ViewModel`
protocol ViewModel {
/// This method is called when `ViewModel` updates itself with `new` data
var didUpdate: (() -> Void)? { get set }
/// This method is called when `ViewModel` changes its state
/// - isLoading: Loading state of ViewModel
/// - loadingMessage: Loading messages to display while ViewModel is loading
var didChangeState: ((_ isLoading: Bool, _ loadingMessage: String?) -> Void)? { get set }
}
protocol Searchable {
func searchFor(keyword: String)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment