UNPKG

@playkit-js/playkit-js-ui

Version:

[![Build Status](https://github.com/kaltura/playkit-js-ui/actions/workflows/run_canary_full_flow.yaml/badge.svg)](https://github.com/kaltura/playkit-js-ui/actions/workflows/run_canary_full_flow.yaml) [![code style: prettier](https://img.shields.io/badge/c

31 lines (27 loc) 1.04 kB
import {mergeDeep} from './merge-deep'; /** * @param {string} component - The component name. * @param {string} oldState - The component old state. * @param {string} action - The action object. * @returns {Object} - The component updated state. */ function getComponentStateFromConfig(component: string, oldState: any, action: any): any { const componentConfig = action.config.components && action.config.components[component]; if (componentConfig) { return mergeDeep(oldState, componentConfig); } return oldState; } /** * @param {string} component - The component name. * @param {string} oldState - The component old state. * @param {string} action - The action object. * @returns {Object} - The component updated state. */ function getComponentStateFromComponentConfig(component: string, oldState: any, action: any): any { if (action.componentAlias === component) { return mergeDeep(oldState, action.config); } return oldState; } export {getComponentStateFromConfig, getComponentStateFromComponentConfig};