We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I am trying to perform a dispatch action from a method. Here is how I am trying
StoreConnector<AppState, AppState>( converter: (store) => store.state, builder: (context, items) => Column( children: <Widget>[ Text(items.rahi), Text(items.mySiteUrl), RaisedButton( child: Text('update rahi'), onPressed: (){_updateRahi(store);}, ), ], ) ),
You can see I have cakked updateRahi method and inside this method
void _updateRahi(store){ var text = status.text; // want to call dispatch action from here store.dispatch('this is some texts'); }
The text was updated successfully, but these errors were encountered:
Hey there -- please see the following discussion: #108
Essentially, you need to convert the Store into a ViewModel like so:
Store
ViewModel
/// Just returns a function that takes in an integer and dispatches an `ItemSelectedAction` StoreConnector<AppState, void Function(int selectedItemId)>( converter: (store) => (int selectedItemId) => store.dispatch(ItemSelectedAction(selectedItemId)), builder: (context, onItemSelected) => RaisedButton( child: Text("Press me!"), onPressed: () => onItemSelected(1), ), ); /// More complex example with a "ViewModel" class _ViewModel { final int itemId; final void Function() onItemSelected; _ViewModel(this.itemId, this.onItemSelected); } StoreConnector<AppState, _ViewModel>( converter: (store) { final itemId = store.state.getMeAnItemId; return _ViewModel( itemId, () => store.dispatch(ItemSelectedAction(itemId)), ); }, builder: (context, viewModel) => RaisedButton( child: Text("Displaying ${viewModel.itemId}"), onPressed: viewModel.onItemSelected, ), );
Sorry, something went wrong.
No branches or pull requests
I am trying to perform a dispatch action from a method. Here is how I am trying
You can see I have cakked updateRahi method and inside this method
The text was updated successfully, but these errors were encountered: