storedValue.binding is now computed property rather than a function

This commit is contained in:
Joe Fabisevich
2022-11-03 21:46:06 -04:00
parent 9bd809e710
commit 3dd4609a19
3 changed files with 6 additions and 6 deletions

View File

@@ -4,7 +4,7 @@ public extension StoredValue {
/// A convenient way to create a `Binding` from a `StoredValue`.
/// - Returns: A `Binding<Item>` of the `StoredValue<Item>` provided.
func binding() -> Binding<Item> {
var binding: Binding<Item> {
Binding(get: {
self.wrappedValue
}, set: {
@@ -18,7 +18,7 @@ public extension AsyncStoredValue {
/// A convenient way to create a `Binding` from an `AsyncStoredValue`.
/// - Returns: A `Binding<Item>` of the `AsyncStoredValue<Item>` provided.
func binding() -> Binding<Item> {
var binding: Binding<Item> {
Binding(get: {
self.wrappedValue
}, set: { value in

View File

@@ -76,10 +76,10 @@ final class AsyncStoredValueTests: XCTestCase {
}
func testStoredBinding() async throws {
XCTAssertEqual(self.$storedBinding.binding().wrappedValue, Binding.constant(BoutiqueItem.sweater).wrappedValue)
XCTAssertEqual(self.$storedBinding.binding.wrappedValue, Binding.constant(BoutiqueItem.sweater).wrappedValue)
try await self.$storedBinding.set(BoutiqueItem.belt)
XCTAssertEqual(self.$storedBinding.binding().wrappedValue, Binding.constant(BoutiqueItem.belt).wrappedValue)
XCTAssertEqual(self.$storedBinding.binding.wrappedValue, Binding.constant(BoutiqueItem.belt).wrappedValue)
}
func testStoredValuePublishedSubscription() async throws {

View File

@@ -84,11 +84,11 @@ final class StoredValueTests: XCTestCase {
func testStoredBinding() async throws {
// Using wrappedValue for our tests to work around the fact that Binding doesn't conform to Equatable
XCTAssertEqual(self.$storedBinding.binding().wrappedValue, Binding.constant(BoutiqueItem.sweater).wrappedValue)
XCTAssertEqual(self.$storedBinding.binding.wrappedValue, Binding.constant(BoutiqueItem.sweater).wrappedValue)
self.$storedBinding.set(BoutiqueItem.belt)
XCTAssertEqual(self.$storedBinding.binding().wrappedValue, Binding.constant(BoutiqueItem.belt).wrappedValue)
XCTAssertEqual(self.$storedBinding.binding.wrappedValue, Binding.constant(BoutiqueItem.belt).wrappedValue)
}
func testPublishedValueSubscription() async throws {