Skip to content

Commit e954634

Browse files
committed
Reorganized docs about code changes
1 parent 47f6f0f commit e954634

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

CHANGELOG.md

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,38 @@
66

77
🆕 Added a new `WeakReferenceMessenger` type. This type is less performant than the other messenger, and uses more memory, and in return only uses weak references to track recipients. This type essentially mirrors the behavior of the `Messenger` type from `MvvmLight`, making the transition easier for developers migrating from that library.
88

9-
🆕 Introduced a new custom delegate to represent message handlers, which also receives the current recipient as additional input parameter. No API changes are required for users registering messages through the `IRecipient<TMessage>` interface, whereas users manually registering will need to modify their code as follows:
9+
🆕 Introduced a new custom delegate to represent message handlers, which also receives the current recipient as additional input parameter (see code changes below).
10+
11+
✅ Renamed `Messenger` to `StrongReferenceMessenger`.
12+
13+
✅ The `WeakReferenceMessenger` is now the default messenger used by the `ObservableRecipient` class.
14+
15+
✅ Changed `ObservableObject` overloads using `Expression<Func<T>>` to be more efficient (see code changes below).
16+
17+
✅ API changes to the `SetPropertyAndNotifyOnCompletion` (as detailed in [this blog post]( https://devblogs.microsoft.com/pax-windows/mvvm-toolkit-preview-3-the-journey-of-an-api/)).
18+
19+
🚨 Removed the `Ioc` class (we will include docs on how to easily start using the `Microsoft.Extensions.DependencyInjection` library directly to work with dependency injection).
20+
21+
## Breaking changes
22+
23+
💥 If you were using the `ObservableObject.SetProperty<T>(Expression<Func<T>>, ...)` overload, the code needs to be updated as follows to replace the LINQ expression with a stateless lambda expression:
24+
25+
```cs
26+
private readonly User user;
27+
28+
public string Name
29+
{
30+
// Preview 2
31+
set => SetProperty(() => user.Name, value);
32+
33+
// Preview 3
34+
set => SetProperty(user.Name, value, user, (u, n) => u.Name = n);
35+
}
36+
```
37+
38+
The syntax is slightly more complex, but results in a 150x speed improvement (that's not a typo), requires no memory allocations at all and no reflection, and ensures that all necessary validation of the arguments can be done at compile time too.
39+
40+
💥 If you were registering message handlers, no API changes are required for messages registered through the `IRecipient<TMessage>` interface. If you were manually registering handlers with the `Action<TMessage>` delegate instead, you will need to modify their code as follows:
1041

1142
```cs
1243
// Preview 2
@@ -32,30 +63,9 @@ Messenger.Register<MyViewModel, MyMessage>(this, (recipient, message) =>
3263
});
3364
```
3465

35-
✅ Renamed `Messenger` to `StrongReferenceMessenger`.
36-
37-
✅ The `WeakReferenceMessenger` is now the default messenger used by the `ObservableRecipient` class.
38-
39-
✅ Changed `ObservableObject` overloads using `Expression<Func<T>>` to be more efficient. For instance, the one used to wrap a non-observable model:
40-
41-
```cs
42-
private readonly User user;
43-
44-
public string Name
45-
{
46-
// Preview 2
47-
set => SetProperty(() => user.Name, value);
48-
49-
// Preview 3
50-
set => SetProperty(user.Name, value, user, (u, n) => u.Name = n);
51-
}
52-
```
53-
54-
The syntax is slightly more complex, but results in a 150x speed improvement (that's not a typo), requires no memory allocations at all and no reflection, and ensures that all necessary validation of the arguments can be done at compile time too.
55-
56-
✅ API changes to the `SetPropertyAndNotifyOnCompletion` (as detailed in [this blog post]( https://devblogs.microsoft.com/pax-windows/mvvm-toolkit-preview-3-the-journey-of-an-api/)).
66+
💥 If you were directly referencing `Messenger.Default` to send messages (ie. outside of the `ObservableRecipient` class, which exposes a `Messenger` property which is unchanged), you'll need to replace that with either `WeakReferenceMessenger.Default` or `StrongReferenceMessenger.Default`, depending on the desired messenger to use.
5767

58-
🚨 Removed the `Ioc` class (we will include docs on how to easily start using the `Microsoft.Extensions.DependencyInjection` library directly to work with dependency injection).
68+
💥 If you want to use the `StrongReferenceMessenger` class for better performance, make sure to pass that to the constructor of the `ObservableRecipient` class, otherwise the `WeakReferenceMessenger.Default` instance will be used.
5969

6070
## Notes
6171

0 commit comments

Comments
 (0)