Skip to content

Commit

Permalink
docs: switch ObservedObject to StateObject (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaker6 authored Feb 9, 2022
1 parent 69dce16 commit a34c5cb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ extension GameScore {
struct ContentView: View {

//: A view model in SwiftUI
@ObservedObject var viewModel = GameScore.query("points" > 2)
@StateObject var viewModel = GameScore.query("points" > 2)
.order([.descending("points")])
.viewModel
@State var name = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ViewModel: ObservableObject {
struct ContentView: View {

//: A view model in SwiftUI
@ObservedObject var viewModel = ViewModel()
@StateObject var viewModel = ViewModel()

var body: some View {
NavigationView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var query = GameScore.query("points" < 11)
struct ContentView: View {

//: A LiveQuery subscription can be used as a view model in SwiftUI
@ObservedObject var subscription = query.subscribe!
@StateObject var subscription = query.subscribe!

var body: some View {
VStack {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ let myQuery = GameScore.query("points" > 9)
struct ContentView: View {

//: A LiveQuery subscription can be used as a view model in SwiftUI
@ObservedObject var subscription = myQuery.subscribe!
@StateObject var subscription = myQuery.subscribe!

var body: some View {
VStack {
Expand Down

0 comments on commit a34c5cb

Please sign in to comment.