public static RedditState Reduce(RedditState state, IAction action) { if (state == null) { state = new RedditState(); } // combineReducer state.selectedSubreddit = SelectedSubredditReducer(state.selectedSubreddit, action); state.postsBySubreddit = PostsBySubredditReducer(state.postsBySubreddit, action); return(state); }
private static bool ShouldFetchPosts(RedditState state, string subreddit) { if (state == null) { return(true); } if (!state.postsBySubreddit.TryGetValue(subreddit, out var post)) { return(true); } if (post.isFetching) { return(false); } return(post.didInvalidate); }