0

I am using flutter-redux for state management in my project using StoreConnector.

Lets say I have a list of songs in the main view and a music player widget in the bottom bar. Everytime a new song is clicked on, the music player widget should make an api call for number of people who listened to that song. So I need to fetch data in this widget not just once but everytime the corresponding store data in _ViewModel for this widget changes.

In react js, we can use ComponentDiDUpdate() lifecycle. I wanted to know if there is something similar in flutter or if there is a best practice for this situation.

Subhash
  • 37
  • 1
  • 7

1 Answers1

1

You can use StoreConnector event listeners:

StoreConnector<AppState, AppState>(
  onDidChange: _onDidChange,
  onWillChange: _onWillChange,
);

Taym95
  • 2,331
  • 13
  • 14
  • can you pls answer this https://stackoverflow.com/questions/56419359/compare-old-view-model-and-current-view-model-in-flutter-redux – Subhash Jun 02 '19 at 22:22