Skip to content

Commit 9e64095

Browse files
committed
corrected error in README.MD
I had named the example Observer Protocol and example Observer Class the same. This is obviously not permitted in Swift, so I have refactored the Protocol to conform to standard Protocol Naming Convention and updated the examples accordingly.
1 parent 40f11be commit 9e64095

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ This not only works for `@ObservedObject` decorated Variables in a SwiftUI `View
6565
First, you would define a Protocol describing the Methods implemented in your *Observer* Class Type that your *Observable* Class can invoke:
6666
```swift
6767
/// Protocol defining what Methods the Obverable Class can invoke on any Observer
68-
protocol DummyObserver: AnyObject { // It's extremely important that this Protocol be constrained to AnyObject
68+
protocol DummyObservable: AnyObject { // It's extremely important that this Protocol be constrained to AnyObject
6969
func onFooChanged(oldValue: String, newValue: String)
7070
func onBarChanged(oldValue: String, newValue: String)
7171
}
@@ -83,7 +83,7 @@ class Dummy: ObservableClass {
8383
}
8484
set {
8585
// Invoke onFooChanged for all current Observers
86-
withObservers { (observer: DummyObserver) in
86+
withObservers { (observer: DummyObservable) in
8787
observer.onFooChanged(oldValue: _foo, newValue: newValue)
8888
}
8989
_foo = newValue
@@ -98,7 +98,7 @@ class Dummy: ObservableClass {
9898
}
9999
set {
100100
// Invoke onBarChanged for all current Observers
101-
withObservers { (observer: DummyObserver) in
101+
withObservers { (observer: DummyObservable) in
102102
observer.onBarChanged(oldValue: _bar, newValue: newValue)
103103
}
104104
_bar = newValue
@@ -108,10 +108,10 @@ class Dummy: ObservableClass {
108108
}
109109
```
110110

111-
We can now define an *Observer* to register with the *Observable*, ensuring that we specify that it implements our `DummyObserver` protocol:
111+
We can now define an *Observer* to register with the *Observable*, ensuring that we specify that it implements our `DummyObservable` protocol:
112112
```swift
113-
class DummyObserver: DummyObserver {
114-
/* Implementations for DummyObserver */
113+
class DummyObserver: DummyObservable {
114+
/* Implementations for DummyObservable */
115115
func onFooChanged(oldValue: String, newValue: String) {
116116
print("Foo Changed from \(oldValue) to \(newValue)")
117117
}

0 commit comments

Comments
 (0)