Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {LoadableContent} from '../../model/loadable-content';
  2. import {NegativeKeywords} from '../../model/recommendations';
  3. import {
  4.     FAILED_TO_LOAD_NEGATIVE_KEYWORDS,
  5.     LOAD_NEGATIVE_KEYWORDS,
  6.     LOADED_NEGATIVE_KEYWORDS,
  7.     NegativeKeywordsAction
  8. } from '../actions/negative-keywords';
  9.  
  10. export interface NegativeKeywordsState {
  11.     negativeKeywords: LoadableContent<NegativeKeywords>;
  12. }
  13.  
  14.  
  15. const initialState: NegativeKeywordsState = {
  16.     negativeKeywords: LoadableContent.loaded(new NegativeKeywords([], 0))
  17. };
  18.  
  19. export function negativeKeywordsReducer(state: NegativeKeywordsState = initialState,
  20.                                            action: NegativeKeywordsAction): NegativeKeywordsState {
  21.     switch (action.type) {
  22.  
  23.         case LOAD_NEGATIVE_KEYWORDS:
  24.             return {
  25.                 negativeKeywords: LoadableContent.loading()
  26.             };
  27.  
  28.         case LOADED_NEGATIVE_KEYWORDS:
  29.             return {
  30.                 negativeKeywords: LoadableContent.loaded(action.result)
  31.             };
  32.  
  33.         case FAILED_TO_LOAD_NEGATIVE_KEYWORDS:
  34.             return {
  35.                 negativeKeywords: LoadableContent.failedToLoad()
  36.             };
  37.  
  38.         default:
  39.             return state;
  40.     }
  41. }
  42.  
  43. export const selectNegativeKeywords = (state: NegativeKeywordsState) => state.negativeKeywords;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement