- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我仍在学习RxJ,并且尝试使用concatMap()不使用嵌套订阅。我希望第一个调用运行,然后在运行第二个请求之前延迟一两秒钟(在第二个请求之前创建数据库记录)。我还想专门为每个请求添加错误处理,以便我可以分别捕获它们的错误。
到目前为止,我有一些东西可以运行请求1,延迟,然后运行请求2。
return this.request_1(postData).pipe(
concatMap(res => of(res).pipe( delay( 2000 ) )),
concatMap(res => this.request_2(parseInt(data.id), parseInt(model['_id'])) )
);
最佳答案
您可以在每个请求中添加catchError
。但是只要您不想改变错误对象,我宁愿在管道的末尾只有一个catchError
。只会将所有错误都带给订户。
然后可以在订阅中完成错误处理本身
const source = of('World').pipe(
concatMap(res => of(res).pipe(
delay(2000),
map(res => res += ' + concat 1')
)),
concatMap(res => of(res).pipe(
map(res => res.h += ' + concat 2')
)),
catchError(err => throwError(err))
);
source.subscribe(
x => console.log(x),
error => console.log('error', error)
);
关于angular - Angular 6 + RxJs-concatMap的错误处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54952297/
是否可以并行执行高阶可观察对象,但在合并结果时仍保留顺序? 我有这样的东西: invoker$: Observable; fetch: (index: number) => Observable; i
我有这个设置: public listenCampaignSelected(){ var campaignSelected$ = this.store .select(store => s
这个问题在这里已经有了答案: Difference between concatMap f xs and concat $ map f xs? (1 个回答) 7年前关闭。 concatMap 是什么
我正在处理一组文件。对于每个文件,我需要请求正确的上传 URL,然后将该文件上传到正确的端点。 concatMap应该仅在前一个值完成后发出。这样,文件就应该被顺序处理。 这是我的代码: filesC
问题 7 来自 99 个 Haskell 问题 展平嵌套列表结构 这是我的解决方案: data NestedList a = Elem a | List [NestedList a] myFlatte
我有一个 37MB bin 文件,我正在尝试将其转换为 ppm 序列。它工作正常,我正在尝试将其用作练习来学习一些分析以及有关 Haskell 中惰性字节串的更多信息。我的程序似乎在 concatMa
我有以下代码: Observable.from(modifiedNodes) .concatMap(node => { return this.Model.setData(no
这个问题已经有答案了: Replace a 3 parameter list-comprehension by using map, concat (3 个回答) 已关闭 3 年前。 如何将列表理解转
我总体上很困惑,并正在寻找关于此代码如何工作的非常详细和解释性的答案: let xs = [1] ++ concatMap (\x -> [x+1,x*10]) xs in xs concatMap
这个问题已经有答案了: Replace a 3 parameter list-comprehension by using map, concat (3 个回答) 已关闭 3 年前。 如何将列表理解转
我在玩>>=今天,试图了解monads,发现了一个有趣的模式。使用列表单子(monad)时,>>=似乎表现得像 concatMap。我四处搜寻,试图找到任何相似之处,特别是在 hackage 的定义中
我试图找到一个行为类似于 concatMap 的运算符,但会丢弃介于两者之间的所有内容。例如, concatMap 执行以下操作: next a start handling a next b nex
可能是一个基本问题,但我有一个 Angular 应用程序调用后端服务来检索一些数据,然后使用该数据进行另一个后端服务调用。 第二次服务调用依赖于第一次成功完成,所以我使用 RxJS 的 concatM
我一直没能找到这个问题的答案,但是 concat map 之间有什么区别?和 map ?具体来说,我有一个让我很困惑的例子: const domainsObservable = this.auth.g
在Stream中我们可以通过flatMap将多维数据打开降维,扁平化处理数据为一维数据。Reactor当然也有这种需求,我们可以使用flatMap和concatMap进行数据的降维处理 flatMap
我读自Foldr Foldl Foldl'由于严格属性,foldl' 对于长的有限列表更有效。我知道它不适合无限列表。 因此,我只对长的有限列表进行比较。 连接映射 concatMap是使用 fold
考虑这个例子:我有一个文件按顺序下载。如果一个下载失败,它应该移动到下一个。伪代码: Observable.from(urls) .concatMap(url -> downloadObservab
我有一个 Observable 链和一个对话框,在一切都完成后会消失。顺序是这样的:1 api调用获取ResponseBody2 取response body进程(非ui线程)3个其他进程(不是ui线
我有 2 个 retrofit 电话需要进行 A 和 B: (A):返回一个ArrayList (B):获取 (A) 的结果,它是一个 ArrayList。 (B) 遍历 ArrayList 并使用每
我用 concatMap以长时间运行的操作一次处理一个项目流。在某些时候,我需要“中断”这个长时间运行的操作,但仅限于当前项目: @Test public void main() throws Int
我是一名优秀的程序员,十分优秀!