Amir Movahedi
Amir Movahedi

Reputation: 1792

Use Rx native instead of Event

I want to convert event code using e.cancel to RX code.

public void CounsumerMethod(object sender, EventArgs e) {
    if (x == 0) {
        e.Cancel = false;
    }
}

Upvotes: 0

Views: 166

Answers (1)

Ana Betts
Ana Betts

Reputation: 74692

You cannot effectively convert this code to proper Rx code, because this is not a Pure event - the caller of the event (i.e. the framework code) will immediately check the "Cancel" value, whereas Rx will not guarantee that it will set that variable in-context. You'll make an Observable that works sometimes and mysteriously fails in other scenarios.

Upvotes: 2

Related Questions