Skip to content

Question: dispatching action on widget initialization #34

Open
@maxlapides

Description

@maxlapides

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 extend StoreConnector.

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 of componentDidMount. 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions