Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }