Reactive Extensions Subscribe calling await

前端 未结 2 1049
逝去的感伤
逝去的感伤 2021-02-13 10:08

I want to perform an async call based for each event raised by a Reactive Extensions Observable. I\'m also trying to keep everything synchronized as I want the async ca

2条回答
  •  孤城傲影
    2021-02-13 10:41

    How about:

    settingsChangedInMemory
        .SelectMany(async _ => await SaveSettings(Extract()))
        .Subscribe(x => Apply(x));
    

    Never put an async in a Subscribe, you always want to put it in a SelectMany instead.

提交回复
热议问题