UNPKG

@wordpress/notices

Version:
25 lines (24 loc) 737 B
// packages/notices/src/store/reducer.ts import { keyedReducer } from "@wordpress/data"; var notices = keyedReducer("context")((state = [], action) => { switch (action.type) { case "CREATE_NOTICE": return [ ...state.filter(({ id }) => id !== action.notice.id), action.notice ]; case "REMOVE_NOTICE": return state.filter(({ id }) => id !== action.id); case "REMOVE_NOTICES": return state.filter(({ id }) => !action.ids.includes(id)); case "REMOVE_ALL_NOTICES": return state.filter(({ type }) => type !== action.noticeType); default: return state; } }); var reducer_default = notices; export { reducer_default as default }; //# sourceMappingURL=reducer.mjs.map