I'm working on a never-ending task that needs to loop continuously in TypeScript.
The next task should only start when the previous one has finished.
I've decided to utilize rxjs for this because it appears to be the most concise approach.
My attempts with interval, queue scheduler, defer, exhaust, and exhaust map haven't been very successful so far.
This is my current code snippet:
function longTask(): void {
// some lengthy process
}
interval(1000)
.pipe(
exhaustMap((x) =>
defer(()=> longTask())
)
.subscribe();
Any assistance would be greatly appreciated.