From ccf76a72c1263db67502cbc320280e941295cd53 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Tue, 30 Jul 2024 11:31:42 +0200 Subject: [PATCH] refactor: Fehler-Action-Parameter in der FetchAsync-Methode optional machen --- src/WindreamHub.Legacy.Client/Models/ModelExtensions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/WindreamHub.Legacy.Client/Models/ModelExtensions.cs b/src/WindreamHub.Legacy.Client/Models/ModelExtensions.cs index 6531a8c..77bd2e0 100644 --- a/src/WindreamHub.Legacy.Client/Models/ModelExtensions.cs +++ b/src/WindreamHub.Legacy.Client/Models/ModelExtensions.cs @@ -16,7 +16,7 @@ namespace WindreamHub.Legacy.Client.Models return new SimplifiedResponse(ok: message.IsSuccessStatusCode, status: message.StatusCode, data: data, error: err); } - public static async Task FetchAsync(this Task> responseAsync, Action next, Action error, CancellationToken cancellationToken = default) + public static async Task FetchAsync(this Task> responseAsync, Action next, Action error = null, CancellationToken cancellationToken = default) { if (cancellationToken.IsCancellationRequested) return; @@ -25,10 +25,10 @@ namespace WindreamHub.Legacy.Client.Models if (res.Ok) next(res.Data); else - error(res.Error); + error?.Invoke(res.Error); } - public static void Fetch(this Task> responseAsync, Action next, Action error, CancellationToken cancellationToken = default) + public static void Fetch(this Task> responseAsync, Action next, Action error = null, CancellationToken cancellationToken = default) { Task.Run(async () => {