@aller/blink
Version:
A library for tracking user behaviour.
37 lines (34 loc) • 843 B
text/typescript
import { BOX_SCREEN_ENTER, PAGE_INIT } from '../actions';
export function singleBox(state = [], action: any) {
switch (action.type) {
case BOX_SCREEN_ENTER: {
return {
...state,
id: action.payload.id,
title: action.payload.title,
height: action.payload.height,
width: action.payload.width,
};
}
default:
break;
}
return state;
}
export default function box(state: { [key: string]: any } = {}, action: any) {
switch (action.type) {
case PAGE_INIT:
return {}; // Flush the store on page initialization
case BOX_SCREEN_ENTER:
if (!action.payload.id) {
return state;
}
return {
...state,
[action.payload.id]: singleBox(state[action.payload.id], action),
};
default:
break;
}
return state;
}