UNPKG

lml-main

Version:

This is now a mono repository published into many standalone packages.

28 lines (22 loc) 836 B
import { PusherMetadataModel } from '../interfaces' import * as Actions from '../actions' export const PUSHER_METADATA_REDUCER_KEY = 'metadata' export interface PusherMetadataState { [channel: string]: PusherMetadataModel } export const initialPusherMetadataState: PusherMetadataState = {} export const pusherMetadataReducer = (state = initialPusherMetadataState, action: Actions.PusherAction) => { switch (action.type) { case Actions.SET_PUSHER_METADATA: { return setMetadata(state, action) } default: return state } } const setMetadata = (state: PusherMetadataState, action: Actions.SetPusherMetadataAction): PusherMetadataState => ({ ...state, [action.channel]: action.metadata })