Skip to content

Instantly share code, notes, and snippets.

@hrvolapeter
Created September 9, 2020 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrvolapeter/e9b2f2762996d07886a03d6f210a9f85 to your computer and use it in GitHub Desktop.
Save hrvolapeter/e9b2f2762996d07886a03d6f210a9f85 to your computer and use it in GitHub Desktop.
import Foundation
extension NoteDetailView {
class ViewModel: ObservableObject {
@Published var note: Note
init(note: Note) {
self.note = note
}
static func newNote() -> NoteDetailView.ViewModel {
self.newNote(parentId: nil)
}
static func newNote(parentId: String?) -> NoteDetailView.ViewModel {
NoteDetailView.ViewModel(note: .init(title: "", content: "", parentId: parentId, tags: []))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment