16 lines
471 B
JavaScript
16 lines
471 B
JavaScript
|
/* Riot WIP, @license MIT */
|
||
|
import { callOrAssign } from '@riotjs/util';
|
||
|
|
||
|
/**
|
||
|
* Compute the component current state merging it with its previous state
|
||
|
* @param {Object} oldState - previous state object
|
||
|
* @param {Object} newState - new state given to the `update` call
|
||
|
* @returns {Object} new object state
|
||
|
*/
|
||
|
|
||
|
function computeComponentState(oldState, newState) {
|
||
|
return Object.assign({}, oldState, callOrAssign(newState));
|
||
|
}
|
||
|
|
||
|
export { computeComponentState };
|