Sorry for the title, I couldn't think of a better one.
I've got this piece of code, which basically:
- filter for valid (non-null) cron epressions' arrays
- map each cron expression to a call to a service
this.formGroup.valueChanges.pipe(
op.filter(v => !!v.cronExpressions),
op.map((v): string[] => v.cronExpressions),
op.map((v: string[]) => v.map(cron =>
this.cronService.getReadableForm(cron).pipe(
op.map(this.toDescription),
op.map((description): CronExpressionModel => ({ cron, description }))
)
)
),
// What now?
).subscribe((cronExpressions: CronExpressionModel[]) => ...) // Expected result
I'd like to get, on subscribe(), the array of CronExpressionModel returned from all the services calls.
I can't wrap my head around this.
Current solution, as per Martin answer:
filter(v => !!v.cronExpressions),
map(v => v.cronExpressions),
map(cronExprs => cronExprs.map(c => this.invokeCronService(c))),
mergeMap(serviceCalls => forkJoin(serviceCalls).pipe(defaultIfEmpty([])))