btroncone / ngrx-examples

@ngrx examples and resources
371 stars 68 forks source link

ASYNC: postsByReddit reducer #11

Open tja4472 opened 8 years ago

tja4472 commented 8 years ago

Should this be?

export interface RedditPostsArray {
    [index: string]: RedditPosts;
}

export const postsByReddit: ActionReducer<RedditPostsArray> = (state: RedditPostsArray = {}, action: Action) => {
    switch (action.type) {
        case INVALIDATE_REDDIT:
        case RECEIVE_POSTS:
        case REQUEST_POSTS:
            return <RedditPostsArray>Object.assign({}, state, {
                [action.payload.reddit]: posts(state[action.payload.reddit], action)
            });
        default:
            return state;
    }
};
btroncone commented 8 years ago

Yep, thanks! Will update soon 👍