You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to propose adding two new widgets to complement the existing ValueStreamBuilder:
ValueStreamListener
A widget that listens to a ValueStream and executes a callback when the stream emits new values, without rebuilding the widget tree. Useful for side effects like showing snackbars or navigation.
Signature:
ValueStreamListener<T>({
requiredValueStream<T> stream,
requiredvoidFunction(BuildContext context, T previous, T current) listener,
requiredWidget child,
Key? key,
})
ValueStreamConsumer
A widget that combines both ValueStreamBuilder and ValueStreamListener functionality, allowing both rebuilding and side effects from a single widget.
Signature:
ValueStreamConsumer<T>({
requiredValueStream<T> stream,
requiredWidgetFunction(BuildContext context, T value) builder,
boolFunction(T previous, T current)? buildWhen,
voidFunction(BuildContext context, T previous, T current)? listener,
Key? key,
})
Notes:
The builder callback uses value instead of data as its parameter name to better align with ValueStream's value-focused nature and its .value getter. This makes the API more intuitive when working with ValueStreams.
Unlike other similar implementations, the listener in ValueStreamConsumer is optional. This design choice allows the Consumer to be used primarily as a builder while maintaining the flexibility to add or remove listeners as needed, without requiring a complete widget swap.
I have implementations of these widgets that I've been using in my projects and would be happy to contribute them via PR in the next few days.
Let me know if you're interested in this contribution and if you'd like to see the PR.
Thanks!
The text was updated successfully, but these errors were encountered:
I would like to propose adding two new widgets to complement the existing ValueStreamBuilder:
A widget that listens to a ValueStream and executes a callback when the stream emits new values, without rebuilding the widget tree. Useful for side effects like showing snackbars or navigation.
Signature:
A widget that combines both ValueStreamBuilder and ValueStreamListener functionality, allowing both rebuilding and side effects from a single widget.
Signature:
Notes:
value
instead ofdata
as its parameter name to better align with ValueStream's value-focused nature and its.value
getter. This makes the API more intuitive when working with ValueStreams.listener
in ValueStreamConsumer is optional. This design choice allows the Consumer to be used primarily as a builder while maintaining the flexibility to add or remove listeners as needed, without requiring a complete widget swap.I have implementations of these widgets that I've been using in my projects and would be happy to contribute them via PR in the next few days.
Let me know if you're interested in this contribution and if you'd like to see the PR.
Thanks!
The text was updated successfully, but these errors were encountered: