Expected behavior:
1) Get all tasks from taskService.getAllTasks()
;
2) Pass the result tasks to filterService.addFilterableTasks()
;
3) Get tasks from filterService.getFilteredTasks()
;
4) Pass the result tasks to searchService.addTasks()
;
5) Get tasks from searchService.getBoardFilteredTasks()
.
this.taskService.getAllTasks().pipe(
tap((allTasks: Task[]) => {
this.filterService.addFilterableTasks(allTasks);
console.log(allTasks) // (1)
}),
switchMapTo(this.filterService.getFilteredTasks()),
tap((tasks: Task[]) => {
this.searchService.addTasks(tasks);
console.log(`passed ${tasks.length} tasks`) // (2)
}),
switchMapTo(this.searchService.getBoardFilteredTasks()) // (3)
).subscribe((tasks: Task[]) => {
/* get the result tasks and show them on a board */
})
Current behavior:
Without line (3):
line 1 => expected array in the console
line 2 => correct number of passed tasks
With line (3):
line 1 and everything further are not triggered. An error says that there are no tasks in searchService.getBoardFilteredTasks
Question:
Is it allowed to use one switchMapTo()
after another?
Or is there another way to implement such?