1.0.1 • Published 3 years ago
ts-schedule v1.0.1
ts-schedule
Statements | Branches | Functions | Lines |
---|---|---|---|
Allows scheduling functionality in TypeScript using decorators.
Prerequisites
npm install ts-schedule
To use decorators in TypeScript, you will need to add the following to your tsconfig.json
:
{
"compilerOptions": {
"experimentalDecorators": true
}
}
Usage
@enableScheduling()
class Foo {
@scheduled(1000) // bar1 will run every 1000ms
bar1() {
console.log('bar1');
}
@scheduled(1000, 5000) // bar2 will run every 1000ms after an intial 5000ms delay
bar2() {
console.log('bar2');
}
}
new Foo();
Output
bar1
bar1
bar1
bar1
bar2
bar1
bar2
bar1