Last active
October 9, 2023 19:18
-
-
Save arrmixer/65b5476f8da1f8771566cc4eeb4e4fd2 to your computer and use it in GitHub Desktop.
Shared ViewModel wrapper for swift
This file contains hidden or 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
// create a new Observable object class to allow the views to observed usign the @StateObject annotation | |
final class RemindersViewModelWrapper: ObservableObject { | |
let viewModel = RemindersViewModel() | |
@Published private(set) var reminders: [Reminder] = [] // stream that the view will listen to within the Obeservable Object | |
init() { | |
viewModel.onRemindersUpdated = { [weak self] items in | |
self?.reminders = items | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment