-
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Modified example :
class QueryWithStreamAndSourceExample extends StatelessWidget {
QueryWithStreamAndSourceExample({super.key});
@SolidState()
int multiplier = 1;
@SolidQuery(useRefreshing: false)
Stream<int> fetchData() {
return Stream.periodic(const Duration(seconds: 1), (i) => i * multiplier);
}
@SolidQuery(useRefreshing: false)
Future<double> fetchDataFromQuery() async {
final stream = fetchData();
var lastValue = 0.0;
await for (final value in stream) {
lastValue = value.toDouble();
}
return lastValue / 3;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('QueryWithStream')),
body: Center(
child: Column(
children: [
Text('Is refreshing: ${fetchDataFromQuery().isRefreshing}'),
fetchDataFromQuery().when(
ready: (data) => Text(data.toString()),
loading: CircularProgressIndicator.new,
error: (error, stackTrace) => Text('Error: $error'),
),
ElevatedButton(
onPressed: fetchData.refresh,
child: const Text('Manual Refresh'),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () => multiplier++,
child: const Icon(Icons.add),
),
);
}
}Unfortunately this arbitrary example doesn't work currently :
@SolidQuery(useRefreshing: false)
Future<double> fetchDataFromQuery() async {
final stream = fetchData();
var lastValue = 0.0;
await for (final value in stream) {
lastValue = value.toDouble();
}
return lastValue / 3;
}We would need a way to get the current value of the @SolidQuery in another reactive @SolidQuery, is there a way to do something like this currently or perhaps a workaround?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels