Last active
February 23, 2018 14:05
-
-
Save Blightwidow/6169fd2d8acd230e06c4ac216fff9aad to your computer and use it in GitHub Desktop.
MVVM ViewModel
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
class accountViewModel { | |
// MARK: Interfaces | |
private var date: Date = Date() { | |
didSet { | |
DispatchQueue.main.async { | |
self.updateDate?(self.date) | |
} | |
} | |
} | |
var updateDate: ((Date) -> Void)? | |
// MARK: Object lifecycle | |
init() { | |
setup() | |
} | |
// MARK: View lifecycle | |
private func setup() { | |
} | |
// MARK: Available calls | |
func fetchDate() { | |
fetchDateFromApi(completion: { fetchedDate in | |
guard let date = fetchedDate else { return } | |
self.date = date | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment