import { setIn } from '@thi.ng/paths' ; import { INITIALIZED , VALUE_UPDATED } from './constants' ; import type { Action } from '../types' ; import type { ConfigState } from './types' ; export function configReducer ( state = null , action ) { switch ( action . type ) { case INITIALIZED : { return action . payload . config ; } case VALUE_UPDATED : { if ( state === null ) return state ; return setIn ( state , action . payload . path , action . payload . value ) ; } } return state ; }