sample code:
import { Log } from "./your-log-decorator";
import { beforeMethod } from "kaop-ts";
class ClassName {
@beforeMethod(Log)
someMethod() {
...
}
}
sample code:
import Catch from "awesome-catch-decorator"
class AnyES6Class {
@Catch(SyntaxError, () => ({}))
static parseResponse(unvalidatedInputValue) {
return JSON.parse(unvalidatedInputValue)
}
}
// will always return an object
AnyES6Class.parseResponse()
AnyES6Class.parseResponse(",,,s,ds,sd,")
AnyES6Class.parseResponse('{ "message": "Okay, I get it" }')
package it self is a bit outdated but u get the basic idea:
sample code:
class SomeClass {
@http({ url: 'localhost/resource'})
public someMethod (params?: any, error?, result?): void {
// error should be null if request was success
}
}
someClassInstance.someMethod()
// $ curl localhost/resource
someClassInstance.someMethod({ id: 1 })
// $ curl localhost/resource?id=1
const prom:Promise<any> = someClassInstance.someMethod()
Usage:
sample code:
const style = `
span { font-size: 20px; color: lightblue; }
`
class ClassName {
@stylesheet(style)
render() {
return <span>something</span>
}
}