OpenSlides/client/src/app/core/mixins.ts

16 lines
527 B
TypeScript
Raw Normal View History

/**
* Mixes all own properties of all baseCtors into the derivedCtor.
* See https://www.typescriptlang.org/docs/handbook/mixins.html
*/
export function applyMixins(derivedCtor: any, baseCtors: any[]): void {
baseCtors.forEach(baseCtor => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
Object.defineProperty(
derivedCtor.prototype,
name,
Object.getOwnPropertyDescriptor(baseCtor.prototype, name)
);
});
});
}