Is there an equivalent of the Task.ContinueWith operator in Rx?

冷暖自知 提交于 2019-12-05 16:06:49

Yes, it's called projection:

o1().SelectMany(_ => o2()).Subscribe();

While Alex is right, the other way you can do this is:

Observable.Concat(
    o1(4),
    o2(6))
  .Subscribe(x => /* Always one, then two */);

Which guarantees that o2 only runs after o1 - as opposed to Merge, which would run them at the same time:

Observable.Merge(
    o1(4),
    o2(6))
  .Subscribe(x => /* Either one or two */);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!