Most useful EcmaScript decorators
import {Debounce, Defaults} from 'es-decorators';
@Defaults({
ammunitionCount: 100
})
class Panzer {
@Debounce(1000, {leading: true})
fire() {
// ...
}
}
@Autobind
binds method to container (e.g. class or object)
@Defaults(props)
props {object}
@Defaults decorator slightly differs from lodash.defaults
@Debounce(duration, [options])
duration {number}
options {object} see lodash.debounce
@Throttle(duration, [options])
duration {number}
options {object} see lodash.throttle
@Memoize([resolver])
resolver {function} see lodash.memoize
@Once
see lodash.once
@Retry([count = 0])
count {number} retry count. 0 means no retries, simply call.
Assumes that decorated function returns promise. The function will be called up tocount
times until it is resolved.
@DecorateInstance(decorator, ...args)
decorator {function}
args {*[]}
@DecorateInstance transforms instance method with provided decorator when it is accessed first time