brianegan/flutter_redux

[Question] Should a store connector be rebuilding and firing events if its not in the foreground?

muzzah opened this issue · 2 comments

Hey Brian,

Me again :) Quick question, I don't know if this relates to the previous discussion we had, but if there is a widget with a store connector that is not in the foreground (that is another widget has been pushed using the navigator), should the StoreConnector of the widget that is not in the foreground be firing events (e.g onWillChange, onDidChange)?

Yo yo :)

Yep! It's a bit funky at first, but if a Widget is listening to a data source (Redux Store, ChangeNotifier, etc) it will continue to rebuild when changes are emitted. Widgets do not call any kind of onPause method like you might see in Android land when a pushing a new Activity.

Thanks Brian. I came across the following
https://api.flutter.dev/flutter/widgets/RouteObserver-class.html

Looks like you can subscribe to route events and know when your widget is pushed or popped etc.

I think this could be a good addition to this library. I find that sometimes the widgets should not really be responding to events, especially if they are far down the stack of visible widgets. This could allow people to flag widgets to not respond to events when not visible, I will be adding this to fix my problem to my widgets.