UNPKG

reducer-class

Version:

Boilerplate free class-based reducer creator. Built with TypeScript. Works with Redux and NGRX. Has integration with immer.

19 lines (18 loc) 818 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const constants_1 = require("./constants"); class ReducerClassMixin { } exports.ReducerClassMixin = ReducerClassMixin; exports.Extend = (...mixins) => (target) => { for (const mixin of mixins) { const mixinKeys = Object.getOwnPropertyNames(mixin.prototype); for (const mixinKey of mixinKeys) { if (!(mixinKey in target.prototype) && mixinKey !== 'constructor') { target.prototype[mixinKey] = mixin.prototype[mixinKey]; const mixinKeyMetadata = Reflect.getMetadata(constants_1.METADATA_KEY_ACTION, mixin.prototype, mixinKey); Reflect.defineMetadata(constants_1.METADATA_KEY_ACTION, mixinKeyMetadata, target.prototype, mixinKey); } } } };