使用RXJS 6按顺序执行一组操作

时间:2018-10-09 17:11:35

标签: rxjs6

我有一个包含其他实体集合的实体。

Catalog => books
        => bookReviews.

我想删除目录,但仅在book&bookReviews完成时删除。

const deleteAllbooks = 
    booksService.getBooksForCustomer(cusId)
        .pipe(
             switchMap(book => book),
             tap(item => console.log('Deleting book:', item),
             map(book => bookService.delete(book)
        );

const deleteAllReviews =
    reviewService.getAllReviews(cusId)
        .pipe(
            switchMap(review => review),
            tap(item => console.log('Deleting review', item),
            map(review => reviewService.delete(review)
    );

const deleteCatalog =
    catalogService.deleteCatalog(cusId)

我想按类似的顺序运行它们

const doDelete = 
    deleteAllBooks
       .pipe(concat(deleteAllReviews,deleteCatalog));

这会导致编译器错误:

TS2345:类型“ Observable”的参数不能分配给类型“ OperatorFunction”的参数。

感谢您的指点,并在此先感谢您。

0 个答案:

没有答案