From 42858678363bc91b68fd29b61fe63eda455bbd83 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Sun, 16 Jun 2024 11:18:16 +0200 Subject: [PATCH] [app_rx] add lastEventOrNull --- app_rx/lib/src/helpers.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app_rx/lib/src/helpers.dart b/app_rx/lib/src/helpers.dart index 56d8dfc..62797c4 100644 --- a/app_rx/lib/src/helpers.dart +++ b/app_rx/lib/src/helpers.dart @@ -112,4 +112,13 @@ class _BroadcastValueStream extends Stream @override T? get valueOrNull => _subject.valueOrNull; + + /// Returns the last emitted event (either data/value or error event). + /// `null` if no value or error events have been emitted yet. + @override + StreamNotification? get lastEventOrNull => hasValue + ? StreamNotification.data(value) + : hasError + ? StreamNotification.error(error) + : null; }