RX Subjects - are they to be avoided?

后端 未结 4 1308
攒了一身酷
攒了一身酷 2020-12-15 05:06

I\'ve had a mini-discussion on the topic in another thread, and would like to have people\'s input on the \"bad\" sides of subjects.

People who frequent the RX forum

4条回答
  •  抹茶落季
    2020-12-15 05:13

    Erik Meijer is thinking in a purely functional way - Subjects are the mutable variables of Rx. So, in general usage he's right - using Subjects is sometimes a way to cop out of Thinking Functionally, and if you use them too much, you're trying to row upstream.

    However! Subject are extremely useful when you're interfacing with the non-Functional world of .NET. Wrapping an event or callback method? Subjects are great for that. Trying to put an Rx "interface" onto some existing code? Use a Subject!

提交回复
热议问题