Options
All
  • Public
  • Public/Protected
  • All
Menu

kaop

semantic-release Greenkeeper badge Image travis version Coverage Status dependencies dev-dependencies downloads Known Vulnerabilities

Lightweight, solid, framework agnostic and easy to use library written in TypeScript to deal with Cross Cutting Concerns and improve modularity in your code.

Short Description (or what is an Advice)

This library provides a straightforward manner to implement Advices in your app. Advices are pieces of code that can be plugged in several places within OOP paradigm like 'beforeMethod', 'afterInstance'.. etc. Advices are used to change, extend, modify the behavior of methods and constructors non-invasively.

For in deep information about this technique check the resources.

Demo

https://jsbin.com/bogecojuvi/edit?js,console

Get started

npm install kaop-ts --save

Use a join point to plug it to any method/class:

import { afterMethod } from 'kaop-ts'

class DummyExample {

  @afterMethod(meta => meta.result *= 2)
  static calculateSomething (num, num2) {
    return num * num2
  }
}

DummyExample.calculateSomething(3, 3) // 18
DummyExample.calculateSomething(5, 5) // 50

Whats new on 3.0

  • Advices no longer use this to access several utilities.
  • Metadata properties have been renamed. Here you can check the reference .
  • JoinPoints support multiple advices:
// join point decorators expect a list of advices
@beforeMethod(advice1, advice2, advice3)
// even you can provide an advice array using spread operator
@beforeMethod(...adviceList)
someMethod() {

}

Docs

Resources

Credits

Made using TypeScript Library Starter

Similar resources

Index

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc