UNPKG

@metamask/snaps-simulation

Version:

A simulation framework for MetaMask Snaps, enabling headless testing of Snaps in a controlled environment

32 lines 1.11 kB
import $reduxjstoolkit from "@reduxjs/toolkit"; const { createSelector, createSlice } = $reduxjstoolkit; /** * The initial notifications state. */ const INITIAL_STATE = { notifications: [], }; export const notificationsSlice = createSlice({ name: 'notifications', initialState: INITIAL_STATE, reducers: { addNotification: (state, action) => { state.notifications.push(action.payload); }, removeNotification: (state, action) => { state.notifications = state.notifications.filter((notification) => notification.id !== action.payload); }, clearNotifications: (state) => { state.notifications = []; }, }, }); export const { addNotification, removeNotification, clearNotifications } = notificationsSlice.actions; /** * Get the notifications from the state. * * @param state - The application state. * @returns An array of notifications. */ export const getNotifications = createSelector((state) => state.notifications, ({ notifications }) => notifications); //# sourceMappingURL=notifications.mjs.map