I'm new to redux/thunk and I'm going through some code that weren't written by me and I'm trying to understand how everything works. When the function refreshPlaylist is dispatched, it has the param id and a callback function. I'm wondering what playlist is referring to in the callback.
Component.jsx
loadData = id => {
const { dispatch } = this.props;
dispatch(
PlaylistThunks.refreshPlaylist(id, playlist => {
dispatch(PlaylistActions.setPlaylistUnderDisplay(playlist));
})
);
}
thunks.js
export const refreshPlaylist = (id, successCallBack) => dispatch => {
PlayListService.getPlaylist(id)
.then(response => {
const playlist = response.data;
PlayListService.getTracklist(id).then(response2 => {
playlist.songs = response2.data.items;
dispatch(Actions.updatePlaylist(playlist));
if (successCallBack) {
successCallBack(playlist);
}
});
})
.catch(e => console.error(e));
response.datafrom thePlayListService.getPlaylist(id)call.successCallBack(playlist)