Rx - can/should I replace .NET events with Observables?

前端 未结 5 1723
挽巷
挽巷 2020-12-12 18:13

Given the benefits of composable events as offered by the Reactive Extensions (Rx) framework, I\'m wondering whether my classes should stop pushing .NET events, and instead

5条回答
  •  旧巷少年郎
    2020-12-12 18:47

    Apart from the fact that your existing eventing code could be terser:

        public event EventHandler ProgressChanged = delegate {};
    
        ...
           set {
              ... 
              // no need for null check anymore       
              ProgressChanged(this, new EventArgs());
       }
    

    I think by switching to Observable you are just moving complexity from the callee to the caller. What if I just want to read the int?

    -Oisin

提交回复
热议问题