mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-03-25 19:01:26 +01:00
Add examples project
This commit is contained in:
26
Examples/Example To-Do App/SwiftUITodo/UserData.swift
Executable file
26
Examples/Example To-Do App/SwiftUITodo/UserData.swift
Executable file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// UserData.swift
|
||||
// SwiftUITodo
|
||||
//
|
||||
// Created by Suyeol Jeon on 03/06/2019.
|
||||
// Copyright © 2019 Suyeol Jeon. All rights reserved.
|
||||
//
|
||||
|
||||
import Combine
|
||||
import SwiftUI
|
||||
|
||||
private let defaultTasks: [Task] = [
|
||||
Task(title: "Read SwiftUI Documentation 📚", isDone: false),
|
||||
Task(title: "Watch WWDC19 Keynote 🎉", isDone: true),
|
||||
]
|
||||
|
||||
final class UserData: BindableObject {
|
||||
let didChange = PassthroughSubject<UserData, Never>()
|
||||
|
||||
@UserDefaultValue(key: "Tasks", defaultValue: defaultTasks)
|
||||
var tasks: [Task] {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user