@rxap/mixin
TypeScript icon, indicating that this package has built-in type declarations

15.0.0 • Public • Published

@rxap/mixin

npm version commitizen friendly styled with prettier Libraries.io dependency status for latest release, scoped npm package npm NPM

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

Keywords

Install

DownloadsWeekly Downloads

250

Version

15.0.0

License

MIT

Unpacked Size

123 kB

Total Files

34

Last publish

Collaborators

  • badry.muenker
  • mmuenker