score:1

export const fetchPostsIfNeeded = subreddit => (dispatch, getState) => {
  dispatch(selectSubreddit(subreddit);
  if (shouldFetchPosts(getState(), subreddit)) {
    return dispatch(fetchPosts(subreddit))
  }
}

// ... elsewhere:

handleChange = (nextSubreddit) => {
  this.props.dispatch(fetchPostsIfNeeded(nextSubreddit));
}

Related Query

More Query from same tag