You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/document/Csharp Design Patterns/docs/Behavioural/Observer.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,18 +3,21 @@
3
3
## Motivation
4
4
5
5
- To be informed when status changed
6
-
-To be informed when certain things happened.
6
+
- To be informed when certain things happened.
7
7
- Listen to events and get notified when they occurs
8
8
9
+
.NET has following builtin types to perform observer pattern.
10
+
9
11
-`INotifyPropertyChanged`
10
12
-`INotifyPropertyChanging`
11
13
-`IObservable<T>`
12
14
-`IObserver<T>`
13
15
-`ObervableCollection<T>`
14
16
-`BindingList<T>`
15
17
16
-
> Observer is the object to be informed when event occurs
17
-
> Observable is the object generating the event.
18
+
> [!NOTE]
19
+
> Observer is the object to be informed when event occurs, informed by passing event args.
20
+
> Observable is the object passes the event args when performing something.
18
21
19
22
## By Event
20
23
@@ -166,7 +169,7 @@ classDiagram
166
169
PlayerEventArgs <|-- OnAttackEventArgs
167
170
```
168
171
169
-
**Observable and Observer do not know each other, the mediator is certain `EventArgs`. Observer handles notifications by different kinds of `EvntArgs`.**
172
+
**Observable and Observer do not know each other, the mediator is certain `EventArgs`. Observer handles notifications by different kinds of `EventArgs`.**
170
173
171
174
- Observable: adds Observers
172
175
- Subscription: as a `IDisposable` pair of Observer and Observable, will be stored on a collection inside Observable.
0 commit comments