I want to show different notification bars for success/error responses, I pass two callBacks to an redux async action in my react component like this:
<Button
onClick={e => this.props.actions.asyncAction(item, this.showSuccessBar, this.showErrorBar)}
/>
where asyncAction looks like this:
export function asyncAction(item, successCallback, errorCallback) {
return (dispatch, getState) => {
dispatch(requestItem(item));
return fetch("api.some_url/items/item")
.then(response => response.json())
.then(json => {
if (json.success) {
dispatch(receivePostsSuccess(reddit, json));
successCallback();
} else {
dispatch(receivePostsFail(reddit, json));
errorCallback();
}
});
}
};
}
Is this considered against the pattern? in other words, Should Notification Bars open according to the state change instead of callBacks?