-
Notifications
You must be signed in to change notification settings - Fork 23
Question: dispatching action on widget initialization #34
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Please give us initState for living! |
The more I think about it, the more I think |
My solution to this has been to create a child stateful widget in between my StoreConnection and the widget that I would normally pass straight to I can then override initState on that widget which gives me a place to dispatch my action. It's a bit tediously boilerplate, but it works. |
@smiLLe has a great PR (38) which solves these issues by including these really useful callbacks |
I'd like to dispatch an action when a widget initializes. Normally, I'd put this kind of logic inside
initState
on a stateful Flutter widget. But, AFAIK, no such feature exists for widgets that extendStoreConnector
.The reason I'd like to do this is so I can do things like make API calls when a widget is initialized. The parallel in the React world would be calling
fetch
inside ofcomponentDidMount
. I think an argument could be made that a better architecture in many cases would be to put the API calls in some middleware that is triggered by a change route action, and this is probably what I'll end up doing. But, I was really interested to hear what the best practice here is. Thanks!The text was updated successfully, but these errors were encountered: