ReactiveUI

Learn how to use the ReactiveUI architectural pattern in .NET MAUI.

ReactiveUI (also known as RxUI) is an architectural pattern that utilizes a combination of the MVVM pattern and reactive programming. Reactive programming involves asynchronous logic to facilitate fully interactive real-time updates. Typically, it consists of the following components:

  • An event, which represents some action that the application listens to. This may be a keystroke, a lifecycle event, a signal from an external system, etc.

  • A call, which represents the action that is triggered by an event.

  • A message, which contains information about the status of an object or any other information about the update.

ReactiveUI is a very popular architectural framework for developing UI applications because it allows developers to build complex real-time applications with relatively little code. This framework is more complex than the standard MVVM, and perhaps in simple scenarios not much is gained from ReactiveUI over standard MVVM. For example, if we have a page that has a single button and a very basic logic associated with it, then using the standard MVVM pattern may be better than using ReactiveUI. However, the more complex the user interface becomes, the more apparent the benefits of ReactiveUI become. So, building applications that perform a lot of data manipulation and that update the UI accordingly is much easier using ReactiveUI.

ReactiveUI basics

ReactiveUI consists of the following components:

  • Observables: These provide access to a data stream or some sort of event.

  • Operators or Commands: These define how the application reads the data or events from the observables and reacts to them.

  • Observers: These define an object that subscribes to the observables and listens to any changes.

Typically, the ViewModel would contain the observable properties and commands, while the View would be updated based on the state returned from the observable objects.

Get hands-on with 1400+ tech skills courses.