UNPKG

vroom-react

Version:
16 lines (14 loc) 509 B
const publisherVideosReducer = (state: string, action: { type: string, payload: any}) => { let tmp switch (action.type) { case 'add': tmp = state.split(',').filter((i: any) => i !== `${action.payload.id}` && i !== '') tmp[tmp.length] = `${action.payload.id}` return tmp.join(',') case 'remove': return state.split(',').filter((i: any) => i !== `${action.payload.id}` && i !== '').join(',') default: return state || '' } } export default publisherVideosReducer