@wordpress/core-data
Version:
Access to and manipulation of core WordPress entities.
25 lines (23 loc) • 758 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/** @typedef {import('../types').AnyFunction} AnyFunction */
/**
* A higher-order reducer creator which invokes the original reducer only if
* the dispatching action matches the given predicate, **OR** if state is
* initializing (undefined).
*
* @param {AnyFunction} isMatch Function predicate for allowing reducer call.
*
* @return {AnyFunction} Higher-order reducer.
*/
const ifMatchingAction = isMatch => reducer => (state, action) => {
if (state === undefined || isMatch(action)) {
return reducer(state, action);
}
return state;
};
var _default = exports.default = ifMatchingAction;
//# sourceMappingURL=if-matching-action.js.map
;