Skip to main content

Crate ferroui_reactiveui

Crate ferroui_reactiveui 

Source
Expand description

ferroui-reactiveui

A port of ReactiveUI (https://github.com/reactiveui/ReactiveUI) to Rust, in the flavour that runs on System.Reactive (here ferroui-reactive), together with the run time of ReactiveUI.Binding: reactive objects, commands, the observation of properties and the bindings of view models and views for MVVM. It depends on nothing of the user interface of FerroUI; the integration with the framework (the scheduler of the dispatcher, the observation of the properties of controls, the views) builds on it.

The modules follow the folders of ReactiveUI.Core and ReactiveUI.Shared, in snake case, and the run time of ReactiveUI.Binding is under binding. Everything public is re-exported at the root, as upstream puts it in the namespaces ReactiveUI and ReactiveUI.Binding:

A view model holds a ReactiveObject and is shared as an Rc:

use ferroui_reactiveui::{reactive_object, reactive_properties, IReactiveNotifyPropertyChanged, ReactiveObject};
use ferroui_reactive::ObservableExt;
use std::cell::Cell;
use std::rc::Rc;

reactive_properties! {
    #[derive(Default)]
    pub struct Counter {
        reactive: ReactiveObject,
        #[reactive]
        count: i32,
    }
}
reactive_object!(Counter);

let counter = Rc::new(Counter::default());
let changes = Rc::new(Cell::new(0));
let seen = changes.clone();
let _subscription = counter.changed().subscribe_next(move |_| seen.set(seen.get() + 1));
counter.set_count(1);
counter.set_count(1);
assert_eq!(changes.get(), 1);

Everything is single-threaded and reference counted, as the object model of FerroUI is (docs/porting/reactive.md, section 5.1). An exception of user code is a panic; where upstream catches one, the port catches the panic (PanicException).

Re-exports§

pub use binding::bindings::*;
pub use binding::builder::*;
pub use binding::command_binding::*;
pub use binding::interactions::*;
pub use binding::interfaces::*;
pub use binding::mixins::*;
pub use binding::observable_for_property::*;
pub use binding::observables::*;
pub use interfaces::*;
pub use mixins::*;
pub use reactive_command::*;
pub use reactive_object::*;
pub use scheduler::*;
pub use binding::view::*;
pub use activation::*;
pub use routing::*;
pub use suspension::*;
pub use builder::*;
pub use change_sets::*;
pub use comparers::*;
pub use reactive_property::*;
pub use registration::*;

Modules§

activation
ReactiveUI.Shared/Activation and Shared/ActivationSignals.cs: the activation of views and view models.
binding
ReactiveUI.Binding (the run time): property observation, output properties and, in later waves, the bindings of views (docs/porting/reactive.md, section 3.2).
builder
The builder of a ReactiveUI application (ReactiveUI.Shared/Builder, with Interfaces/IViewModule.cs and Mixins/BuilderMixins*.cs): Splat’s application builder with the services, schedulers, converters and state of ReactiveUI, the replacement of the former RxApp initialization.
change_sets
The change sets of ReactiveUI (ReactiveUI.Core/ChangeSets, ReactiveUI.Core/Mixins/ChangeSetMixins.cs and Shared/Platform/ChangeSetBinder.cs): the changes of a notifying collection as a stream of batches of per-item changes, the light layer that replaced DynamicData inside ReactiveUI.
comparers
The comparers (ReactiveUI.Core/Comparers): orders built by chaining keys (OrderedComparer<T>::order_by(..).then_by(..)).
interfaces
The interfaces of ReactiveUI.Core and ReactiveUI.Shared (Interfaces/) that are not those of commands, routing, suspension or activation: the change notifications of reactive objects and the errors of their pipelines.
mixins
Mixins (ReactiveUI.Shared/Mixins): the extension methods of observables (ObservableMixins, SwitchSubscribeMixins, the logging mixins) and AutoPersist.
platform
The helpers that the platforms of ReactiveUI share (Shared/Platform, Shared/ViewContractObservableHelpers.cs, Shared/ViewHostResolution.cs): small observables and sinks without operator pipelines, the view contract of the view hosts, and their view lookup.
reactive_command
ReactiveCommand (ReactiveUI.Core/ReactiveCommand and ReactiveUI.Shared/ReactiveCommand): commands whose executions are observables, with the streams of their state (CanExecute, IsExecuting, ThrownExceptions), and ICommand, the command a view executes.
reactive_object
ReactiveObject (ReactiveUI.Core/ReactiveObject, ReactiveUI.Shared/ReactiveObject): the base of view models, which notifies the changes of its properties as events and observables, with the suppression and delay of the notifications, and the macros that write a view model’s reactive object and properties.
reactive_property
ReactiveProperty (ReactiveUI.Core/ReactiveProperty, ReactiveUI.Shared/ReactiveProperty): a property that is its own observable, with validation through INotifyDataErrorInfo, and the shared arguments of its notifications.
registration
The registration of ReactiveUI’s services (ReactiveUI.Core/Registration, ReactiveUI.Shared/Registration), with the interfaces it uses (IRegistrar, IWantsToRegisterStuff, IPlatformOperations) and the registration of views (MutableDependencyResolverExtensions, MutableDependencyResolverAOTExtensions).
routing
ReactiveUI.Shared/Routing and ReactiveUI.Core/Routing: the navigation stack of a screen and the message bus.
scheduler
ReactiveUI.Shared/Scheduler: the subject that delivers on a scheduler.
suspension
ReactiveUI.Shared/Suspension: the suspension and resumption of an application.

Macros§

reactive_object
Makes a type that holds a ReactiveObject a reactive object: writes its INotifyPropertyChanged (with as_notify_property_changing), INotifyPropertyChanging, IEnableLogger, IReactiveObject and IHandleObservableErrors.
reactive_properties
Declares a view model’s struct with its notifying properties (ReactiveUI.SourceGenerators’ [Reactive]).
settable_prop
A SettableProperty from getters: the path of prop! and the setter set_<last getter> of the object that owns the last property.
view_for
Implements IActivatableView, IViewFor and IViewForOf<VM> for a view.

Structs§

PanicException
The error of a panic of user code, caught where upstream catches an exception: the message of the panic.
RxCacheSize
The sizes of the caches of ReactiveUI (RxCacheSize): the memoizing caches of view location and of the observation of properties.
RxSchedulers
The schedulers that ReactiveUI’s objects run their work on (RxSchedulers), settable for tests and by the integration with the user interface.
RxState
The state of ReactiveUI that its objects share (RxState): the handler of the errors that no thrown_exceptions subscriber handles.
RxSuspension
The suspension host of the application, for the events of the life of its process, such as its suspension and resumption on a mobile device (RxSuspension).
UnhandledErrorException
The error of a pipeline that broke because nothing handled its error (UnhandledErrorException): what RxState::default_exception_handler panics with when an object implementing IHandleObservableErrors errors and nothing subscribes to its thrown_exceptions.

Traits§

IThreadAffineSequencer
A scheduler bound to one thread, which can tell whether the calling thread is that thread (IThreadAffineSequencer), as a dispatcher can. In the Reactive flavour a sequencer is an IScheduler.