Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About dispatch and async effect #112

Closed
my9074 opened this issue Mar 8, 2019 · 3 comments
Closed

About dispatch and async effect #112

my9074 opened this issue Mar 8, 2019 · 3 comments

Comments

@my9074
Copy link

my9074 commented Mar 8, 2019

I am doing an asynchronous operation through the redux thunk in the LoginAction and calling reducer . Then I want to call Navigator in submitLoginForm for page jumps. However, because dispatch seems to be unable to return a promise, the logic is unreasonable. Unless the Navigator is placed in the redux thunk. I have seen the simple-navigation-example example . But I think the logic of route jumps should sometimes not be included in redux.

void submitLoginForm(BuildContext context) async {
       // ....
       _getStore()?.dispatch(LoginAction(_getStore(), context, userTag));
       
       // execute prior to the asynchronous operation
       Navigator.pushAndRemoveUntil(
          context,
          MaterialPageRoute(builder: (BuildContext context) => HomeState()),
          (Route<dynamic> route) => false,
       );
  }

new StoreBuilder<AppState>(builder: (context, store) {
     return RaisedButton(
     child: Text('Next'),
     onPressed: () => submitLoginForm(context),
   );
}),
@tudor07
Copy link

tudor07 commented Nov 27, 2020

@my9074 have you found a solution?

@brianegan
Copy link
Owner

Redux thunk allows to return Futures now. This Should be working at this point!

@tudor07
Copy link

tudor07 commented Mar 19, 2021

@brianegan do you think you can create an example on how to use it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants