|
| 1 | +# API changes in Preview 4: |
| 2 | + |
| 3 | +🆕 Reintroduced `Ioc` class |
| 4 | + |
| 5 | +🆕 Added new `ObservableObject.OnPropertyChanged(PropertyChangedEventArgs)` overload |
| 6 | + |
| 7 | +🆕 Added new `ObservableObject.OnPropertyChanging(PropertyChangingEventArgs)` overload |
| 8 | + |
| 9 | +🆕 Added new `TrySetProperty` methods to `ObservableValidator` |
| 10 | + |
| 11 | +✅ The `OnPropertyChanged(string)` and `OnPropertyChanging(string)` overloads with a string param are no longer virtual (💥) |
| 12 | + |
| 13 | +✅ Added notification support to `IAsyncRelayCommand.CanBeCanceled` property |
| 14 | + |
| 15 | +✅ Improved notification logic for other `IAsyncRelayCommand` properties |
| 16 | + |
| 17 | +✅ Added notification support to `ObservableValidator.HasErrors` property |
| 18 | + |
| 19 | +✅ Minor performance/memory usage improvements and bug fixes |
| 20 | + |
| 21 | +## Breaking changes |
| 22 | + |
| 23 | +💥 If you were overriding `OnPropertyChanged(string)` or `OnPropertyChanging(string)`, you should now override the overloads taking `PropertyChangedEventArgs` and `PropertyChangingEventArgs` instead, and move your additional logic there. |
| 24 | + |
| 25 | +## A note on the `Ioc` class |
| 26 | + |
| 27 | +The `Ioc` class exposes similar APIs to the ones in Preview 2, but it now doesn't include a direct reference to `Microsoft.Extensions.DependencyInjection`. You can add a reference to any DI library you wish to use, and then you can use the `Ioc.Default.ConfigureServices(IServiceProvider)` method to initialize the `Ioc.Default` instance. From there, you'll be able to use it normally just like in Preview 2. For instance: |
| 28 | + |
| 29 | +```cs |
| 30 | +// Preview 2 |
| 31 | +Ioc.Default.ConfigureServices(services => |
| 32 | +{ |
| 33 | + services.AddSingleton<ILogger, Logger>(); |
| 34 | + services.AddSingleton<IDialogService, DialogService>(); |
| 35 | + // Other services... |
| 36 | +}); |
| 37 | + |
| 38 | +// Preview 3 |
| 39 | +Ioc.Default.ConfigureServices( |
| 40 | + new ServiceCollection() |
| 41 | + .AddSingleton<ILogger, Logger>() |
| 42 | + .AddSingleton<IDialogService, DialogService>() |
| 43 | + .BuildServiceProvider()); |
| 44 | +``` |
| 45 | + |
| 46 | +Here we're using the `ServiceCollection` class from the `Microsoft.Extensions.DependencyInjection` library, but you're free to use any other DI library as well - the `Ioc` class only needs an input `IServiceProvider` instance to work. |
| 47 | + |
1 | 48 | # API changes in Preview 3:
|
2 | 49 |
|
3 | 50 | 🆕 New `ObservableValidator` class, which supports the [`INotifyDataErrorInfo`](https://docs.microsoft.com/dotnet/api/system.componentmodel.inotifydataerrorinfo) interface.
|
|
0 commit comments