malgogi-rx-straw is rxjs utility library.
Using NPM:
npm i --save @malgogi-rx-straw/core
Using YARN:
yarn add @malgogi-rx-straw/core --save
cron is wrapper function of moment, node-cron
cron('* * * * * *')
.subscribe((utcTimeInMillis: number) => {
console.log(`task was started at ${utcTimeInMillis}`);
// do task
})
interval(1000)
.pipe(circuitBreaker<number, number>({
failureThreshold: 30,
execute: (source) => {
// do business logic.
return 1;
},
fallback: () => {
// fail action.
return 2;
},
}))
.pipe(take(3))
.subscribe({
next(item) { console.log('You can get a 1 or 2') },
complete() { done(); }
});