RX Subjects - are they to be avoided?

后端 未结 4 1320
攒了一身酷
攒了一身酷 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条回答
  •  猫巷女王i
    2020-12-15 05:08

    Seems like a lot of commenters are talking past each other.

    Last time I used a Subject was when I needed to pass a delegate to a middleware in an initialisation call so it could call me back when something happened. The delegate had the familiar event args signature, but I couldn't use FromEvent because there was no event.

    I didn't feel bad about it - I didn't see any other choice.

    Basically I used Subjects only when I'm originating some event and putting it into the Rx world, or when I need a handle to some future subscriber that hasn't arrived yet. Subjects let me link what I've got now to a later subscriber.

提交回复
热议问题