UNPKG

@magicbell/react-headless

Version:
18 lines 803 B
import { uniqBy } from 'ramda'; /** * Function to set props on a notification store. The notifications are merged * unless `options.reset` is true. * * @param store Notifications store * @param props Props to set to the store * @param options.reset Do not prepend notifications to the store * @returns Store */ export default function setStoreProps(store, props, options = { reset: false }) { const { notifications = [], ...meta } = props; const allNotifications = options.reset ? notifications : uniqBy((notification) => notification.id, options.prepend ? [...notifications, ...store.notifications] : [...store.notifications, ...notifications]); return { context: store.context, notifications: allNotifications, ...meta }; } //# sourceMappingURL=setStoreProps.js.map