I have a task flow that will queue until a Subject signal is called using the .zip() operator. The subject of the signal subscribes to the current task. I also try to monitor progress in this task.
What I was trying to do was use .publish() to multicast the Observable task, so that I could let the Sign Subscribe to .last() task signal to trigger detection, as well as subscribe to the overall progress of the outliers tasks.
It seems to work. However, when I look at what is being printed, it looks like my Observable factory receives a call on every call to .subscribe() , although I used .publish() . I donβt understand how multicast works? I figured that .publish() ed Observable would be created using the factory, and this singular instance would be split, but it's cold until .connect() was called.
My task runner
Note the .defer() , which calls the tasker .
"use strict"; const { Observable, Subject, BehaviorSubject } = Rx;
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/5.5.6/Rx.js"></script>
My way out
Notice how you see several calls for the caller with the tasker called for N and the factory body is called. However, before any progress tasker() , tasker() is called again with the next TASK_ID . The result seems correct, because Task[MyTask0] does not skip any indexes, only TASK_ID s.
tasker called for 0 Task[MyTask0][started] [queuedTasks$][next]: Task[MyTask0][0%] tasker called for 1 Task[MyTask0][started] [queuedTasks$][next]: Task[MyTask0][20.688413934455674%] [queuedTasks$][next]: Task[MyTask0][32.928520335195564%] [queuedTasks$][next]: Task[MyTask0][42.58361384849108%] [queuedTasks$][next]: Task[MyTask0][73.1297043008671%] [queuedTasks$][next]: Task[MyTask0][100%] tasker called for 2 Task[MyTask1][started] [queuedTasks$][next]: Task[MyTask1][0%] tasker called for 3 Task[MyTask1][started] [queuedTasks$][next]: Task[MyTask1][37.16513927245511%] [queuedTasks$][next]: Task[MyTask1][47.27771448102375%] [queuedTasks$][next]: Task[MyTask1][60.45983311604027%] [queuedTasks$][next]: Task[MyTask1][100%] tasker called for 4 Task[MyTask2][started] [queuedTasks$][next]: Task[MyTask2][0%] tasker called for 5 Task[MyTask2][started] [queuedTasks$][next]: Task[MyTask2][32.421275902708544%] [queuedTasks$][next]: Task[MyTask2][41.30332084025583%] [queuedTasks$][next]: Task[MyTask2][77.44113197852694%] [queuedTasks$][next]: Task[MyTask2][100%] [queuedTasks$][complete] Complete
source share