vonbalaji
vonbalaji

Reputation: 249

Reactive Extensions vs Event Aggregator

I am new to Reactive Extensions. I understand that Rx observes for any changes (at runtime) to the underlying object and notifies when changed to the subscribers.

Consider the Rx for events, which checks for any events and publish those changes to the subscribes. similarly we have event aggregators, which publishes the events to subscribers. Both are doing the same work. Is both serving same purpose. do we have any differences between both.

Thanks for your response

Upvotes: 3

Views: 2413

Answers (1)

Lee Campbell
Lee Campbell

Reputation: 10783

Rant

In my experience, EventAggregators are singletons that invert the direction of responsibility so that UI's can send each other messages and pervert the domain abstractions. I personally think the EventAggregators (w.r.t Prism specifically) is the right answer to the wrong question.

Generally I think that where an EventAggregator is being used, they should be replaced with a call to an appropriate domain entity or service, which may then expose the result of the action as an Event(Rx or otherwise). Now using IoC relevant parties can have the relevant implementation injected to it and then they can subscribe to the event (again Rx or otherwise).

--Rant over--

To better answer your actual question however, I think if you do use an EventAggregator, your question probably is actually "Should I expose the notifications as .net Events or as Rx Observable sequences (IObservable)"

I which case, I don't see a lot of difference. If there is no requirement for sheduling/concurrency control, composition of events/notifications or transormation of the sequences (like throttling or buffering) then you current use of events will be fine.

Upvotes: 1

Related Questions