This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent update loop when using ObservableObjects (fixes #10)
- Loading branch information
1 parent
e23cc7e
commit 3a20859
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import SwiftUI | ||
|
||
class ObservablePublishedModel: ObservableObject { | ||
@Published var searchText = "" | ||
} | ||
|
||
struct ObservablePublishedTest: View { | ||
@ObservedObject var viewModel = ObservablePublishedModel() | ||
|
||
var body: some View { | ||
List { | ||
Text("foo") | ||
} | ||
.navigationBarSearch($viewModel.searchText) | ||
} | ||
} | ||
|
||
struct ObservablePublishedTest_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ObservablePublishedTest() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// I was unable to get this test to work, but I'm leaving it in as a reminder for the future. | ||
|
||
//import XCTest | ||
// | ||
//class ObservablePublishedTests: UITest { | ||
// func testObservablePublishedMetric() throws { | ||
// selectTest("Observable Published") | ||
// | ||
// measure(metrics: [XCTCPUMetric(application: app)]) { | ||
// app.children(matching: .any).firstMatch.slowSwipeDown(offset: 0.5, distance: 0.1) | ||
// | ||
// // Ensure the searchbar exists. | ||
// let navBar = app.navigationBars.firstMatch | ||
// XCTAssertTrue(navBar.children(matching: .searchField).firstMatch.exists, "Searchbar exists") | ||
// } | ||
// } | ||
//} |