UNPKG

@runicjs/runic

Version:

A lightweight, type-safe vanilla JS state management library

11 lines (10 loc) 410 B
import mergeDeep from 'lodash/merge'; /** * Merge the given state with the current state. * @param store - The store to merge the state into. * @param partialState - The state to merge into the store. * @param mergeFn - The function to use to merge the state. */ export default function mergeState(store, partialState, mergeFn = mergeDeep) { store.setState(mergeFn(store.getState(), partialState)); }