A code example illustrating the difference between the paradigms of async/await and Reactive (Rx) extension?

后端 未结 3 1164
天命终不由人
天命终不由人 2021-01-30 15:14

Both the System.Reactive extension for .NET and new C# 5.0 (.NET 4.5) async/await pursue (or based on) future and promises constructs paradigm (approach).

Can you gi

3条回答
  •  粉色の甜心
    2021-01-30 15:30

    I like the table in the Reactive documentation: http://reactivex.io/intro.html

    I have my own take on it where i add a third dimension non-composable/composable.

    Non-composable:
    
           |  Single Item   | Multiple items
     ------|----------------|----------------
     Sync  | Function       | Iterable
     Async | Async function | Observable
    
    Composable:
    
           |      Single Item      |       Multiple items
     ------|-----------------------|----------------------------
     Sync  | Higher order function | Linq/Ramda/java.util.stream
     Async | Future/promise        | Rx observable
    

    And mind you that depending on the implementation, you can have futures and rx observables that can act both synchronously or asynchronously depending on whether what you are trying to do with them is synchronous or asynchrounous

提交回复
热议问题