From b56cd35042868c8e5187f87a6ecc23ab9ff12378 Mon Sep 17 00:00:00 2001 From: "Michael W. Aziz" Date: Sun, 11 May 2025 12:24:25 -0400 Subject: [PATCH] [SYNC] --- .../src/widgets/future_presenter.widget.dart | 12 ++++++------ .../src/widgets/presenter_controller.widget.dart | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/src/presenting/src/widgets/future_presenter.widget.dart b/lib/src/presenting/src/widgets/future_presenter.widget.dart index 2efda6a..baebd52 100644 --- a/lib/src/presenting/src/widgets/future_presenter.widget.dart +++ b/lib/src/presenting/src/widgets/future_presenter.widget.dart @@ -63,8 +63,8 @@ class _AstromicFuturePresenterState extends State> //s1 --State // //s1 --Controllers & Listeners - widget.controller.getRefreshStream(widget.id).listen((_) { - _refreshFuture(); // Force future recreation on refresh + widget.controller.getRefreshStream(widget.id).listen((uA) { + _refreshFuture(updatedArgs: uA); // Force future recreation on refresh }); //s1 --Controllers & Listeners // @@ -121,17 +121,17 @@ class _AstromicFuturePresenterState extends State> } //S1 -- Method to reinitialize or update `_future` with a new instance - void _refreshFuture() { + void _refreshFuture({Map? updatedArgs}) { // Increment the refresh key to ensure a unique future instance _refreshKey++; setState(() { - _initializeFuture(); + _initializeFuture(updatedArgs: updatedArgs); }); } //S1 -- Method to reinitialize or update `_future` with a new instance - void _initializeFuture() { - widget.controller.setProvidedArguments(widget.neededArguments ?? {}); + void _initializeFuture({Map? updatedArgs}) { + widget.controller.setProvidedArguments(updatedArgs ?? widget.neededArguments ?? {}); _future = widget.controller.getFuture(widget.id)?.then((dynamic result) => result as T?); } //!SECTION diff --git a/lib/src/presenting/src/widgets/presenter_controller.widget.dart b/lib/src/presenting/src/widgets/presenter_controller.widget.dart index 5acd497..d78c74f 100644 --- a/lib/src/presenting/src/widgets/presenter_controller.widget.dart +++ b/lib/src/presenting/src/widgets/presenter_controller.widget.dart @@ -5,7 +5,7 @@ import 'dart:async'; class AstromicPresenterController { late final Map args)? fetch, int c)> _futures; late final Map args)?> _streams; - late final Map> _futureRefreshers; + late final Map?>> _futureRefreshers; @@ -13,7 +13,7 @@ class AstromicPresenterController { Map args)? fetch, int startCycle)> futures = const {}, Map args)?> streams = const {}, }) : _futures = futures.map((k, v) => MapEntry(k, (v.$1, v.$2))), - _futureRefreshers = futures.map((k, v) => MapEntry(k, StreamController.broadcast())), + _futureRefreshers = futures.map((k, v) => MapEntry(k, StreamController?>.broadcast())), _streams = streams; Map providedArguments = {}; @@ -46,7 +46,7 @@ class AstromicPresenterController { } /// Get the refresh stream of a future using it's ID. - Stream getRefreshStream(String id) { + Stream?> getRefreshStream(String id) { assert(_futures.containsKey(id), 'did you add a future with this id?'); return _futureRefreshers[id]!.stream; @@ -60,10 +60,10 @@ class AstromicPresenterController { } /// Refresh a future using it's ID. - void refreshFuture(String id) { + void refreshFuture(String id, {Map? updatedArgs}) { assert(_futures.containsKey(id), 'did you add a future with this id?'); - _futureRefreshers[id]!.add(null); + _futureRefreshers[id]!.add(updatedArgs); } /// Dispose of a future using it's ID.