@rxap/mixin
A collection of typescript decorators.
Installation
ng add @rxap/mixin
Setup the package @rxap/mixin for the workspace.
Guides
use the typescript mixin concept with ease.
Basic example
class DisableFeature {
// will not be mixin the Concrete class
public disabled: boolean = false;
public disable(): void {
this.disabled = true;
}
public enable(): void {
this.disabled = false;
}
}
class ValidateFeature {
// will not be mixin the Concrete class
public isValid: boolean = true;
public get isInvalid(): boolean {
return !this.isValid;
}
public validate(): void {}
}
import { mixin } from '@rxap/mixin';
interface Concrete extends DisableFeature, ValidateFeature {}
@mixin(DisableFeature, ValidateFeature)
class Concrete {
// this method will not be overwritten with the
// ValidateFeature.validate method
public validate(): boolean {
return true;
}
}
Resulting Class at runtime
class Concrete {
public get isInvalid(): boolean {
return !this.isValid;
}
public validate(): boolean {
return true;
}
public disable(): void {
this.disabled = true;
}
public enable(): void {
this.disabled = false;
}
}
Schematics
ng-add
Setup the package @rxap/mixin for the workspace.
ng g @rxap/mixin:ng-add
Option | Type | Default | Description |
---|