From 240b96a96a8aba66f4856a76f313f0d5f35c6931 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Mon, 17 Dec 2018 15:28:08 -0500 Subject: [PATCH] Added WeakEventManager --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 3c3abfd..a6b551a 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,20 @@ public event EventHandler CanExecuteChanged public void RaiseCanExecuteChanged() => _weakEventManager.HandleEvent(this, EventArgs.Empty, nameof(CanExecuteChanged)); ``` +- `WeakEventManager` + +```csharp +readonly WeakEventManager _errorOcurredEventManager = new WeakEventManager(); + +public event EventHandler ErrorOcurred +{ + add => _errorOcurredEventManager.AddEventHandler(value); + remove => _errorOcurredEventManager.RemoveEventHandler(value); +} + +public void RaiseErrorOcurred(string message) => _weakEventManager.HandleEvent(this, message, nameof(ErrorOcurred)); +``` + ## AsyncAwaitBestPractices.MVVM Allows for `Task` to safely be used asynchronously with `ICommand`: