Skip to content

Commit 5244c22

Browse files
committed
Added more notes on the breaking changes
1 parent e954634 commit 5244c22

File tree

1 file changed

+47
-23
lines changed

1 file changed

+47
-23
lines changed

CHANGELOG.md

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,20 @@
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 (see code changes below).
9+
🆕 Introduced a new custom delegate to represent message handlers, which also receives the current recipient as additional input parameter (💥 breaking change, see code changes below).
1010

11-
✅ Renamed `Messenger` to `StrongReferenceMessenger`.
11+
✅ Renamed `Messenger` to `StrongReferenceMessenger` (💥).
1212

13-
✅ The `WeakReferenceMessenger` is now the default messenger used by the `ObservableRecipient` class.
13+
✅ The `WeakReferenceMessenger` is now the default messenger used by the `ObservableRecipient` class (💥).
1414

15-
✅ Changed `ObservableObject` overloads using `Expression<Func<T>>` to be more efficient (see code changes below).
15+
✅ Changed `ObservableObject` overloads using `Expression<Func<T>>` to be more efficient (💥).
1616

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/)).
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/), 💥).
1818

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).
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, 💥).
2020

2121
## Breaking changes
2222

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-
4023
💥 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:
4124

4225
```cs
@@ -67,6 +50,47 @@ Messenger.Register<MyViewModel, MyMessage>(this, (recipient, message) =>
6750

6851
💥 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.
6952

53+
💥 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:
54+
55+
```cs
56+
private readonly User user;
57+
58+
public string Name
59+
{
60+
// Preview 2
61+
set => SetProperty(() => user.Name, value);
62+
63+
// Preview 3
64+
set => SetProperty(user.Name, value, user, (u, n) => u.Name = n);
65+
}
66+
```
67+
68+
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.
69+
70+
💥 If you were using `SetPropertyAndNotifyOnCompletion`, change the code as follows:
71+
72+
```csharp
73+
// Preview 2
74+
private Task<string> myTask;
75+
76+
public Task<string> MyTask
77+
{
78+
get => myTask;
79+
set => SetPropertyAndNotifyOnCompletion(ref myTask, () => myTask, value);
80+
}
81+
82+
// Preview 3
83+
private TaskNotifier<string> myTask;
84+
85+
public Task<string> MyTask
86+
{
87+
get => myTask;
88+
set => SetPropertyAndNotifyOnCompletion(ref myTask, value);
89+
}
90+
```
91+
92+
💥 If you were using the `Ioc` class, we will provide docs to illustrate how to setup a custom service container using the `Microsoft.Extensions.DependencyInjection` library soon. The temporary link with the preview docs for this is available [here](https://github.com/windows-toolkit/MVVM-Samples/blob/feature/preview2-update/docs/mvvm/Ioc.md).
93+
7094
## Notes
7195

7296
For additional info and discussion, see the related issue [here](https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/3428).

0 commit comments

Comments
 (0)