Created
April 8, 2019 09:20
-
-
Save apptects/1982ad378681f515dc73b55cd77f648d to your computer and use it in GitHub Desktop.
Redux Reducer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AppState reducer(AppState oldState, dynamic action) { | |
| if(action is ChangeSearchTextAction) { | |
| return oldState.copyWith(searchText: action.searchText); | |
| } else if (action is UpdateTrackItemsAction) { | |
| return oldState.copyWith(trackItems: action.trackItems); | |
| } else if (action is PlayAudioUrlAction) { | |
| return oldState.copyWith(activePlayingAudioUrl: action.audioUrl); | |
| } else if (action is StopAudioAction) { | |
| return oldState.copyWith(activePlayingAudioUrl: ''); | |
| } else if (action is CompletedAudioAction) { | |
| return oldState.copyWith(activePlayingAudioUrl: '', currentAudioDuration: Duration()); | |
| } else if (action is AudioDurationChangedAction) { | |
| return oldState.copyWith(currentAudioDuration: action.duration); | |
| } else if (action is AlbumDetailsAction) { | |
| return oldState.copyWith(albumId: action.albumId); | |
| } else if (action is AlbumTrackItemsAction) { | |
| return oldState.copyWith(albumItems: action.trackItems, albumReleaseDate: action.albumReleaseDate); | |
| } | |
| return oldState; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment